Re: Simulating OS semaphore behavior
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Fri, 25 Aug 2006 17:09:47 +0200
On 25 Aug 2006 08:00:48 -0700, REH wrote:
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.
That looks like a classic automatic event for multiple tasks. Make Signal
an entry:
protected body Event is
entry Wait when Signal'Count > 0 is
begin
null;
end Wait;
entry Signal when Wait'Count = 0 is
begin
null;
end Signal;
end Event;
Signal is blocked until all waiting tasks get released. There is no race
condition because fresh attempts to Wait are blocked if a signal is
pending.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Simulating OS semaphore behavior
- From: Jean-Pierre Rosen
- Re: Simulating OS semaphore behavior
- From: REH
- Re: Simulating OS semaphore behavior
- References:
- Simulating OS semaphore behavior
- From: REH
- Simulating OS semaphore behavior
- Prev by Date: Simulating OS semaphore behavior
- Next by Date: Re: Simulating OS semaphore behavior
- Previous by thread: Simulating OS semaphore behavior
- Next by thread: Re: Simulating OS semaphore behavior
- Index(es):