From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,922e1768d5791765 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Simulating OS semaphore behavior Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1156518048.848919.126340@75g2000cwc.googlegroups.com> <3zrqu2whdwk2.1fobni2jyzalh.dlg@40tude.net> Date: Sat, 26 Aug 2006 10:39:36 +0200 Message-ID: <1gx5jdfxrewj6.19ufu2gqaakge.dlg@40tude.net> NNTP-Posting-Date: 26 Aug 2006 10:39:19 CEST NNTP-Posting-Host: 7dce3cb6.newsspool3.arcor-online.net X-Trace: DXC=hiake4YIgNeIkjb;<8iR=aMcF=Q^Z^V3h4Fo<]lROoRa4nDHegD_]Red[I\27\l:1h[6LHn;2LCVn[eFVCR>:d3e X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6390 Date: 2006-08-26T10:39:19+02:00 List-Id: 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. 2. There is no guaranty that all signals will be delivered to all tasks, some might be still running while the event is pulsed. In general it is not a reliable publisher-subscriber service, but just a pulse event. Under system load, events might get lost or ghosted. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de