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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,922e1768d5791765,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!75g2000cwc.googlegroups.com!not-for-mail From: "REH" Newsgroups: comp.lang.ada Subject: Simulating OS semaphore behavior Date: 25 Aug 2006 08:00:48 -0700 Organization: http://groups.google.com Message-ID: <1156518048.848919.126340@75g2000cwc.googlegroups.com> NNTP-Posting-Host: 192.35.35.34 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1156518054 5033 127.0.0.1 (25 Aug 2006 15:00:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 25 Aug 2006 15:00:54 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: 75g2000cwc.googlegroups.com; posting-host=192.35.35.34; posting-account=lnUIyw0AAACoRB2fMF2SFTIilm8F10q2 Xref: g2news2.google.com comp.lang.ada:6375 Date: 2006-08-25T08:00:48-07:00 List-Id: 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