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-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!news2.telebyte.nl!news-fra1.dfn.de!news-lei1.dfn.de!news.uni-weimar.de!news.uni-jena.de!not-for-mail From: Adrian Knoth Newsgroups: comp.lang.ada Subject: Re: C omega Date: 5 Jun 2004 22:06:12 GMT Organization: loris.TV Message-ID: References: NNTP-Posting-Host: ppc201.mipool.uni-jena.de X-Trace: fsuj29.rz.uni-jena.de 1086473172 24555 141.35.13.101 (5 Jun 2004 22:06:12 GMT) X-Complaints-To: news@rz.uni-jena.de NNTP-Posting-Date: 5 Jun 2004 22:06:12 GMT User-Agent: slrn/0.9.8.0 (Linux) Xref: g2news1.google.com comp.lang.ada:1138 Date: 2004-06-05T22:06:12+00:00 List-Id: Pascal Obry wrote: > class ReaderWriter > { > ReaderWriter() { idle (); } > > public void Shared() & async idle() {s (1); } > public void Shared() & async s(int n) { s(n+1); } > public void ReleaseShared() & async s(int n) { > if (n == 1) idle (); else s(n-1); > } > public void Exclusive() & async idle() {} > public void ReleaseExclusive() {idle (); } > } > > I'm not sure to fully understand the code above, but it looks quite complex > to me :) Looks pretty much like semaphore-handling (Dijkstra?). Access to a shared value (not shown here) is handled. When you call the the Shared()-function for an instance of ReaderWriter it checks whether this resource is idle and if so, sets s to 1. If it is already used by others it increments the value of waiting processes by one. The ReleaseShared might be called to let one process say he's no longer willingly to access this shared value, so the number is decremented. If there is only one process left using it the state is changed to idle. Function Eclusive seems not to be implemented or it is a builtin function and there is nothing more to do. ReleaseExclusive marks the resource as available (dile). The constructor lets new instances be idle. > What is interesting is that the same code(*) in Ada (not compiled) is: 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. -- mail: adi@thur.de http://adi.thur.de PGP: v2-key via keyserver Leute, die mehr als ein xterm offen haben, kann man ja wohl sowieso nicht ernst nehmen. (Felix von Leitner in dcoul-tng@socha.net)