comp.lang.ada
 help / color / mirror / Atom feed
From: Pascal Obry <pascal@obry.org>
Subject: C omega
Date: 05 Jun 2004 16:25:52 +0200
Date: 2004-06-05T14:25:52+00:00	[thread overview]
Message-ID: <u8yf2jd3j.fsf@obry.org> (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



             reply	other threads:[~2004-06-05 14:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-05 14:25 Pascal Obry [this message]
2004-06-05 17:49 ` C omega 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
replies disabled

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