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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,aef3b280a3831a63 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: C omega From: James Rogers References: <2if4rkFm3j4bU1@uni-berlin.de> Message-ID: User-Agent: Xnews/5.04.25 Date: Sun, 06 Jun 2004 02:21:20 GMT NNTP-Posting-Host: 12.73.182.212 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1086488480 12.73.182.212 (Sun, 06 Jun 2004 02:21:20 GMT) NNTP-Posting-Date: Sun, 06 Jun 2004 02:21:20 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:1145 Date: 2004-06-06T02:21:20+00:00 List-Id: Roland Illig wrote in news:2if4rkFm3j4bU1@uni- berlin.de: > Adrian Knoth wrote: >> I wouldn't say it's the same code. Unfortunately you haven't mentioned >> the website where you found this example. Otherwise it would be >> possible to see what is really ment instead of wild guessing. > > http://www.google.de/search?q=public+void+Shared+async+idle+&ie=UTF-8 > > http://research.microsoft.com/~nick/polyphony/intro.htm It would appear from these links that the concurrency in C omega is taken directly from polyphonic C# (or perhaps C omega is a new name for polyphonic C#). The original example: class ReaderWriter { ReaderWriter() { Idle(); } void Exclusive() & private async Idle() { } void ReleaseExclusive() { Idle(); } void Shared() & private async Idle() { S(1); } void Shared() & private async S(int n) { S(n+1); } void ReleaseShared() & private async S(int n) { if (n == 1) Idle(); else S(n-1); } } is clearly an example of a read/write lock. The public methods Exclusive(), ReleaseExclusive(), Shared(), and ReleaseShared() are synchronous methods. They will not complete until a matching private asynchronous method (in this case Idle() or S()) completes. This code produces a behavior similar to the following Ada code: protected lock is entry Exclusive; procedure Release_Exclusive; entry Shared; entry Release_Shared; private N : Natural := 0; Idle : Boolean := True; end lock; protected body lock is entry Exclusive when Idle is begin Idle := False; return; procedure Release_Exclusive is begin Idle := True; end Release_Exclusive; entry Shared when Idle or N > 0 is begin Idle := False; N := N + 1; end Shared; entry Release_Shared when N > 1 is begin N := N - 1; if N = 0 then Idle := True; end if; end Release_Shared; end lock; Note that my Ada explicitly sets Idle to false whereas the C# (or C omega) code simply fails to call Idle(). The weakness in algorithm is that a writer can simply call Release_Exclusive immediately before calling Exclusive. This will cause a collision between shared and exclusive access. In other words, the example contains a fatal flaw. Jim Rogers