From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] vfork and paging From: rog@vitanuova.com MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20011004135646.9C81519A7F@mail.cse.psu.edu> Date: Thu, 4 Oct 2001 15:09:00 +0100 Topicbox-Message-UUID: fd610c90-eac9-11e9-9e20-41e7f4b1d025 > There are (at least) two libraries providing CSP-style channels for Java: > > http://www.cs.ukc.ac.uk/projects/ofa/jcsp > http://www.rt.el.utwente.nl/javapp/ and they both (well, especially jcsp) look substantially more complex (and awkward) than the plan 9 threads library, let alone Limbo... i took a simple example from CTJ and wondered what it looked like under the various systems: Limbo: for (i := 0; i < 20; i++) { alt { n := <-inChannel[0] => ... do something with n n := <-inChannel[1] => ... do something with n } } Plan 9: int i, n; Alt alts[3]; alts[0].c = inChannel[0]; alts[0].v = &n; alts[0].op = CHANRCV; alts[1].c = inChannel[1]; alts[1].v = &n; alts[1].op = CHANRCV; alts[2].op = CHANEND; for (i = 0; i < 20; i++) { switch(alt(alts)) { case 0: ... do something with n break; case 1: ... do something with n break; } } CTJ: Integer n = new Integer(); // n is an Object Process alt = new Alternative(new Guard[] { new Guard(inChannel[0], new Process() { public void run() { inChannel[0].read(n); ... do something with n } }), new Guard(inChannel[1], new Process() { public void run() { inChannel[1].read(n); ... do something with n } }) }; for (int i=0; i<20; i++) { alt.run(); } JCSP: i couldn't quickly work out how to do it with jcsp. it has about 40 classes just for the basic primitives... the plan 9 thread library has 38 functions *in total*. basically, when it comes down to it, there's no substitute for decent language-level primitives. though it's nice to see there are others around that acknowledge the inadequacies of the conventional schemes... rog.