* C omega
@ 2004-06-05 14:25 Pascal Obry
2004-06-05 17:49 ` Wes Groleau
2004-06-05 22:06 ` Adrian Knoth
0 siblings, 2 replies; 13+ messages in thread
From: Pascal Obry @ 2004-06-05 14:25 UTC (permalink / raw)
Something quite interesting. Microsoft is going to add some concurrency
support in C-omega. There is a paper on the link I gave in a previous message.
They present the classic Reader-Writer paradigm using the C-omega chord
(only 5 chords they say) implementation, here it is:
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 :)
What is interesting is that the same code(*) in Ada (not compiled) is:
protected Reader_Writer is
function Read return Integer;
procedure Write (X : in Integer);
private
State : Integer;
end Reader_Writer;
protected body Reader_Writer is
function Read return Integer is
begin
return State;
end Read;
procedure Write (X : in Integer) is
begin
State := X;
end Write;
end Reader_Writer;
But of course they have given some modula-3 code to compare to the C-omega
one! Isn't it fair ?!?
Pascal.
(*) I suppose it is the same code by reading the description they gave about
the ReaderWriter C-omega implementation.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-05 14:25 C omega Pascal Obry
@ 2004-06-05 17:49 ` Wes Groleau
2004-06-05 22:06 ` Adrian Knoth
1 sibling, 0 replies; 13+ messages in thread
From: Wes Groleau @ 2004-06-05 17:49 UTC (permalink / raw)
Pascal Obry wrote:
> Something quite interesting. Microsoft is going to add some concurrency
> support in C-omega. There is a paper on the link I gave in a previous message.
This reminds me of a thirty-year-old (?) advertising slogan
from DEC: "Digital has it now!"
I guess they wanted us to think
"You don't have to wait for _________"
but every time I saw it, I thought,
"OK, we're a little slow, but we finally have ________"
--
Wes Groleau
Nobody believes a theoretical analysis -- except the guy who did it.
Everybody believes an experimental analysis -- except the guy who did it.
-- Unknown
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-05 14:25 C omega Pascal Obry
2004-06-05 17:49 ` Wes Groleau
@ 2004-06-05 22:06 ` Adrian Knoth
2004-06-05 23:55 ` Roland Illig
` (2 more replies)
1 sibling, 3 replies; 13+ messages in thread
From: Adrian Knoth @ 2004-06-05 22:06 UTC (permalink / raw)
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)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-05 22:06 ` Adrian Knoth
@ 2004-06-05 23:55 ` Roland Illig
2004-06-06 2:21 ` James Rogers
2004-06-06 9:49 ` Pascal Obry
2004-06-06 22:14 ` Georg Bauhaus
2 siblings, 1 reply; 13+ messages in thread
From: Roland Illig @ 2004-06-05 23:55 UTC (permalink / raw)
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
Roland
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-05 23:55 ` Roland Illig
@ 2004-06-06 2:21 ` James Rogers
2004-06-06 2:53 ` Wes Groleau
2004-06-06 9:47 ` C omega Pascal Obry
0 siblings, 2 replies; 13+ messages in thread
From: James Rogers @ 2004-06-06 2:21 UTC (permalink / raw)
Roland Illig <roland.illig@gmx.de> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
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
1 sibling, 1 reply; 13+ messages in thread
From: Wes Groleau @ 2004-06-06 2:53 UTC (permalink / raw)
James Rogers wrote:
> 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#).
So we endured bad coffee-related puns ad nauseum
and now that they've tapered off, Microsoft
is going to fill the boid with bad music puns?
--
Wes Groleau
People would have more leisure time if it weren't
for all the leisure-time activities that use it up.
-- Peg Bracken
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-06 2:21 ` James Rogers
2004-06-06 2:53 ` Wes Groleau
@ 2004-06-06 9:47 ` Pascal Obry
2004-06-06 12:32 ` James Rogers
1 sibling, 1 reply; 13+ messages in thread
From: Pascal Obry @ 2004-06-06 9:47 UTC (permalink / raw)
James Rogers <jimmaureenrogers@att.net> writes:
> is clearly an example of a read/write lock.
In that case my first Ada example does exactly that, no ?
I do not want to translate word-for-word the C-omega example.
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-05 22:06 ` Adrian Knoth
2004-06-05 23:55 ` Roland Illig
@ 2004-06-06 9:49 ` Pascal Obry
2004-06-06 22:14 ` Georg Bauhaus
2 siblings, 0 replies; 13+ messages in thread
From: Pascal Obry @ 2004-06-06 9:49 UTC (permalink / raw)
Adrian Knoth <adi@thur.de> writes:
> I wouldn't say it's the same code. Unfortunately you haven't mentioned
> the website where you found this example.
As I said, it was on another message I post the same day :)
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-06 9:47 ` C omega Pascal Obry
@ 2004-06-06 12:32 ` James Rogers
0 siblings, 0 replies; 13+ messages in thread
From: James Rogers @ 2004-06-06 12:32 UTC (permalink / raw)
Pascal Obry <pascal@obry.org> wrote in news:uzn7hhvb6.fsf@obry.org:
>
> James Rogers <jimmaureenrogers@att.net> writes:
>
>> is clearly an example of a read/write lock.
>
> In that case my first Ada example does exactly that, no ?
> I do not want to translate word-for-word the C-omega example.
Actually your first Ada example was better. It did not contain
the pathological behavior of the C-omega example.
Jim Rogers
^ permalink raw reply [flat|nested] 13+ messages in thread
* [off-topic] bad puns
2004-06-06 2:53 ` Wes Groleau
@ 2004-06-06 18:09 ` Wes Groleau
0 siblings, 0 replies; 13+ messages in thread
From: Wes Groleau @ 2004-06-06 18:09 UTC (permalink / raw)
Wes Groleau wrote:
> and now that they've tapered off, Microsoft
> is going to fill the boid with bad music puns?
And 'boid' was a typo, not a bad pun.
--
Wes Groleau
"Would the prodigal have gone home if
the elder brother was running the farm?"
-- James Jordan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-05 22:06 ` Adrian Knoth
2004-06-05 23:55 ` Roland Illig
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
2 siblings, 2 replies; 13+ messages in thread
From: Georg Bauhaus @ 2004-06-06 22:14 UTC (permalink / raw)
Adrian Knoth <adi@thur.de> wrote:
: Pascal Obry <pascal@obry.org> wrote:
:
:> class ReaderWriter
:> {
...
:> }
:>
:> I'm not sure to fully understand the code above, but it looks quite complex
:> to me :)
:
: Looks pretty much like semaphore-handling (Dijkstra?).
They hint at it on the Polyphonic pages IIRC. If you look at
the names of those involved in developing C om, you will find
people who know Ada (Luca Cardelli somehow did ring a bell or two)
and other non-C languages.
<rant>Thus, they know how it should be done. But I guess that
they mustn't do the right thing, for marketing reasons:
- "Just" adding concurrency somehow to a well known programming language
is popular. In particular if the change "just" adds well known concepts
like semaphores. To the programmer: "you just have to ..., and everything
is under your control". (Euphemistically for something else...
By analogy everything is under control when you write at object code
level...)
- They could recommend a language with a track record, an O-O
language that has generic types, subprogram objects, a
simple but useful tasking model at language level, garbage
collection, a C interface, and design by contract.
A language that was among the first to be integrated with .NET,
in cooperation with Microsoft.
It is not a "Microsoft language" though.
- Stepwise refinement of a programming language leaves room
for improvement. Both at the language design level, and
at the "new features, less bugs, new language used" level
in vendor produce (programs). Improvements can be sold.
But OTOH, maybe they find out something new from which the world
will profit.</rant>
It is interesting to see how the languages arrive at ideas that have
been present in Ada for a while know (at least that is what I see
being a dilettante). Maybe there should be a new commercial language
with mostly Ada syntax and semantics, using a fair amount of curly
braces, and known not to be used by the weapon makers, but: with a
different name and a new history. I guess it could be an interesting
offer.
-- Georg Bauhaus
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-06 22:14 ` Georg Bauhaus
@ 2004-06-07 11:17 ` I R T
2004-06-07 15:45 ` Adrian Knoth
1 sibling, 0 replies; 13+ messages in thread
From: I R T @ 2004-06-07 11:17 UTC (permalink / raw)
Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> writes:
> people who know Ada (Luca Cardelli somehow did ring a bell or two)
> and other non-C languages.
Cardelli is very well known in the type theory and functional programming
fields.
If he is involved in C omega, it should well be worth a look.
See:
http://www.luca.demon.co.uk/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: C omega
2004-06-06 22:14 ` Georg Bauhaus
2004-06-07 11:17 ` I R T
@ 2004-06-07 15:45 ` Adrian Knoth
1 sibling, 0 replies; 13+ messages in thread
From: Adrian Knoth @ 2004-06-07 15:45 UTC (permalink / raw)
Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> wrote:
> being a dilettante). Maybe there should be a new commercial language
> with mostly Ada syntax and semantics, using a fair amount of curly
> braces, and known not to be used by the weapon makers, but: with a
> different name and a new history. I guess it could be an interesting
> offer.
You can sell it right now. Just call it a integrated something
and use sed to replace "begin" by { and "end" by }, also
tackling stuff like "end loop" and "end if" ;)
--
mail: adi@thur.de http://adi.thur.de PGP: v2-key via keyserver
Geh sterben. Und nimm Deinen geistig behinderten Freund mit.
(Robin S. Socha in dcoul.misc)
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2004-06-07 15:45 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-05 14:25 C omega Pascal Obry
2004-06-05 17:49 ` Wes Groleau
2004-06-05 22:06 ` Adrian Knoth
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox