Join Patterns

7 views
Skip to first unread message

Andrew Francis

unread,
Dec 6, 2010, 9:12:35 AM12/6/10
to python-csp
Hi Folks:

I know this isn't a PyCSP question per se but has anyone looked into
implementing join patterns? Join patterns are synchronization
mechanism that waits for several channel operations to become ready
before proceeding. If select/alt is about or'ing, then join is about
and'ing. saw join patterns mentioned in the Golang-nuts mailing list a
few months ago and the Go team didn't see quite see the point. Reading
the literature, these things are powerful and I have seen
implementations for Erlang, Lua, and Java. I started to do the initial
"research" implementing join in Stackless Python (a sister CSP
implementation of sorts) and I wondered if anyone looked at it.

Cheers,
Andrew

Tony Ibbs

unread,
Dec 6, 2010, 2:30:56 PM12/6/10
to pytho...@googlegroups.com

Possibly straying even further off topic, KBUS (a lightweight, Linux kernel based messaging system - I talked about it at EuroPython2010, so that's my interest declared) allows one to say that a message can only be delivered when all recipients are able to receive it (or, at least, able to have it added to their to-be-read queues).

(KBUS is at http://code.google.com/p/kbus/, and its documentation is reachable from there too.)

So if A, B and C have all bound to receive messages with a particular message name, then when S sends a message with that name, S can mark it "ALL OR WAIT", which means that if the incoming queues for any of A, B or C are full, then "send" will return -EAGAIN (the traditional Un*x way of indicating that one should, indeed, try again) - one can then use poll/select to wait for the send to succeed, or just choose to discard it and give up.

Similarly, S can also mark the message "ALL OR FAIL", in which case the send will just fail (with -EBUSY) if it can't deliver to all interested recipients.

We suspected that these would probably be most useful in debugging message systems, rather than in normal life. but they did seem important/interesting use cases.

Tibs

Sarah Mount

unread,
Dec 6, 2010, 2:50:38 PM12/6/10
to pytho...@googlegroups.com

python-csp has "barriers" which are in the csp.guards module.

I believe barriers (from bulk-synchronous processing / BSP) are the
same thing as the "join" primitives you mention. The idea of a
barrier, is, as you say that any number of processes can "enrol" on
the barrier, and then block until all the enrolling processes have
synchronised on the barrier. A process can also "retire" from a
barrier, which is the opposite of enrolling.

This is a more general synchronisation primitive than ALTing, as Alt
objects will select a single guard on which to synchronise. I think
most modern implementations of CSP have something like barriers, JCSP
has it and of course many implementations are derivatives of JCSP as
the Kent group has contributed a lot to the state of the art in CSP
implementations.

Cheers,

Sarah

--
Sarah Mount, Senior Lecturer, University of Wolverhampton
website:  http://www.snim2.org/
twitter: @snim2

Reply all
Reply to author
Forward
0 new messages