Simulating OS semaphore behavior
- From: "REH" <spamjunk@xxxxxxxxxxx>
- Date: 25 Aug 2006 08:00:48 -0700
I am porting some code from VxWorks and Ada 83 to another OS using Ada
95. VxWorks' has a sempahore API I want to replicate with purely Ada
95 constructs, such as protected types. The function is semFlush which
basically will release all the tasks currently blocked on the semaphore
but leave it locked, thus any new tasks that attempt to take the
semaphore will block. I just cannot figure out a simple way to do it.
Abstractly, I want to allow an arbitrary number tasks to wait for a
particular event, and when the event occurs, wake all those tasks.
Thereafter, tasks can again block waiting for the next occurrence.
Something like:
protected type Event is
entry Wait;
procedure Signal;
end Event;
Implementing the above for one task seems simple enough, but how would
it been done for an arbitrary number such that the behavior is:
1. Wait's guard is initially false.
2. some tasks call Wait.
3. Signal is called.
4. Wait's guard becomes true.
5. all tasks currently queued on Wait are allowed to continue.
6. Wait's guard becomes false.
Any ideas would be greatly appreciated,
REH
.
- Follow-Ups:
- Re: Simulating OS semaphore behavior
- From: Dmitry A. Kazakov
- Re: Simulating OS semaphore behavior
- Prev by Date: Re: protected type interrupts
- Next by Date: Re: Simulating OS semaphore behavior
- Previous by thread: ANN: GtkAda contributions v1.2
- Next by thread: Re: Simulating OS semaphore behavior
- Index(es):
Relevant Pages
|