Re: Simulating OS semaphore behavior



"REH" <spamjunk@xxxxxxxxxxx> 8/25/2006 8:25 AM >>>

Dmitry A. Kazakov wrote:
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.


Ah, just what I love: simple and elegant. Thank you!

It is just simply beautiful, sweet and elegant solution. I had
implemented similar to Jean-Pierre's. I already changed to Dmitry's
implementation. This is another reason that Ada is in my heart.

AV
.