From: Richard Beton (richard.beton_at_email.domain.hidden)
Date: 2000-09-26 14:35:39
M_Boosten wrote:
...
For example:
Barier
synchronise(myDataContribution) RETURNS
dataCollection
In words:
1. every process contributes its data to the synchronisation.
2. every process receives the collected contribution.
See SEMAPHOREs, RESOURCEs, EVENTs and BUCKETs
(formerly: Higher Levels of Process Synchronisation in occam) by Welch &
Wood
http://wotug.ukc.ac.uk/parallel/occam/projects/occam-for-all/hlps/hlps.txt.
"Channels are not enough" is the opening introduction. The article
describes additions to occam (specifically via the Kroc compiler)
1a) SEMAPHORE allows exclusive read/exclusive write access to shared
data/simple channels
1b) RESOURCE locks are a modified form of semaphore originally intended
for efficient distributed processor networks (can achieve same with
semaphores, however)
2) EVENT barrier synchronisation, which allows groups of threads to meet
at a given point in time, deterministically.
3) BUCKET synchronisation, which is a variation on barrier
synchronisation. except that it is non-deterministic. With bucket
synchronisation, waiting processes are released by explicit command,
which can happen at any time.
Here is the example given in the HLPS article that shows EVENT
synchronisation in use (in occam2 with extensions)
#USE "utils"
PROC event.test (CHAN OF BYTE keyboard, SHARED CHAN OF BYTE screen,
error)
--{{{ client
PROC client (VAL INT id, n.clients, EVENT e, SHARED CHAN OF BYTE out)
INT n:
SEQ
n := id
WHILE TRUE
SEQ
... wait n seconds
--{{{ say ready to synchronise
CLAIM out
SEQ
out.number (id, 0, out)
out.string (" ready to synchronise*c*n", 0, out)
--}}}
SYNC e
--{{{ tell the world
CLAIM out
SEQ
out.string ("==> ", 40, out)
out.number (id, 0, out)
out.string (" over the barrier ...*c*n", 0, out)
--}}}
n := (n.clients + 1) - n -- simple variation for the
timeout
:
--}}}
VAL INT n.clients IS 10:
--{{{ client network (serviced by the screen channel)
PAR n = 0 FOR n.clients EVENT e
client (n + 1, n.clients, e, screen)
--}}}
:
This demonstrates a simple SPMD network of processes synchronising on an
EVENT barrier. Each process
is cyclic, waiting for a variable amount of time before synchronising
once per cycle.
To follow up Marcel's point, it would be more interesting to formulate an
example that shows data swapping on every barrier. Actually, this is
getting to sound rather like Bulk Synchronous Programming (BSP) from
Oxford. Too busy to come up with such an example just now, I'll raise it
as an exercise for the reader! ;-)
Rick
[ Part 2, "Card for Richard Beton" Text/X-VCARD (Name: ]
[ "richard.beton.vcf") 16 lines. ]
[ Unable to print this part. ]
This archive was generated by hypermail 2.1.7 on 2004-10-31 20:03:54 GMT
© Copyright WoTUG
All rights reserved