comp.lang.ada
 help / color / mirror / Atom feed
From: Adrian Knoth <adi@thur.de>
Subject: Re: C omega
Date: 5 Jun 2004 22:06:12 GMT
Date: 2004-06-05T22:06:12+00:00	[thread overview]
Message-ID: <slrncc4guk.69i.adi@ppc201.mipool.uni-jena.de> (raw)
In-Reply-To: u8yf2jd3j.fsf@obry.org

Pascal Obry <pascal@obry.org> 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)



  parent reply	other threads:[~2004-06-05 22:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-05 14:25 C omega Pascal Obry
2004-06-05 17:49 ` Wes Groleau
2004-06-05 22:06 ` Adrian Knoth [this message]
2004-06-05 23:55   ` Roland Illig
2004-06-06  2:21     ` James Rogers
2004-06-06  2:53       ` Wes Groleau
2004-06-06 18:09         ` [off-topic] bad puns Wes Groleau
2004-06-06  9:47       ` C omega Pascal Obry
2004-06-06 12:32         ` James Rogers
2004-06-06  9:49   ` Pascal Obry
2004-06-06 22:14   ` Georg Bauhaus
2004-06-07 11:17     ` I R T
2004-06-07 15:45     ` Adrian Knoth
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox