From: "REH" <me@you.com>
Subject: Re: Simulating OS semaphore behavior
Date: Sat, 26 Aug 2006 13:34:50 GMT
Date: 2006-08-26T13:34:50+00:00 [thread overview]
Message-ID: <_5YHg.29199$8j3.16338@twister.nyroc.rr.com> (raw)
In-Reply-To: 1gx5jdfxrewj6.19ufu2gqaakge.dlg@40tude.net
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1519 bytes --]
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:1gx5jdfxrewj6.19ufu2gqaakge.dlg@40tude.net...
> On Fri, 25 Aug 2006 19:31:53 +0200, Jean-Pierre Rosen wrote:
>
>> Dmitry A. Kazakov a �crit :
>>> 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.
>>
>> However, this will cause the signaling task to wait until some task
>> calls wait.
>
> Why? The Signal's barrier is open when the Wait's queue is empty.
>
> Surely there are subtleties with the above:
>
> 1. The same task might get the same event twice if it anew queues itself
> to
> Wait before emptying the queue.
I want to avoid this.
How about:
protected type Event is
entry Wait;
procedure Signal;
private:
Arrived : Boolean := False;
entry Wait_More;
end Event;
protected body Event is
entry Wait when not Arrived is
requeue Wait_More;
end Wait;
procedure Signal is
begin
Arrived := True;
end Signal;
entry Wait_More when Arrived is
Arrived := Wait_More'Count > 0;
end Wait_More;
end Event;
next prev parent reply other threads:[~2006-08-26 13:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-25 15:00 Simulating OS semaphore behavior REH
2006-08-25 15:09 ` Dmitry A. Kazakov
2006-08-25 15:25 ` REH
2006-08-25 17:31 ` Jean-Pierre Rosen
2006-08-26 8:39 ` Dmitry A. Kazakov
2006-08-26 13:34 ` REH [this message]
2006-08-26 13:42 ` jimmaureenrogers
2006-08-27 14:00 ` Simon Wright
2006-08-26 20:18 ` Dmitry A. Kazakov
2006-08-26 20:29 ` REH
2006-08-27 17:07 ` Dmitry A. Kazakov
2006-08-27 18:02 ` Simon Wright
2006-08-27 22:28 ` REH
-- strict thread matches above, loose matches on Subject: below --
2006-08-31 16:24 Anh Vo
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox