[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Synchronous Communication = Swap



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
 
 
 
 
 
 

begin:vcard 
n:Beton;Richard
tel;pager:ICQ: 56840977
tel;cell:MSN/Hotmail: richardbeton@xxxxxxxxxxx
tel;fax:01794 833434
tel;work:01794 833458
x-mozilla-html:TRUE
url:http://www.beton.freeserve.co.uk/
org:Roke Manor Research Limited;Internet Technology & Networks
adr:;;Roke Manor: http://www.roke.co.uk/;;;SO51 0ZN;UK
version:2.1
email;internet:richard.beton@xxxxxxxxxx
title:Internet Consultant
note;quoted-printable:The information contained in this e-mail is confidential and must =0D=0Anot be passed to any third party without permission. This =0D=0Acommunication is for information only and shall not create =0D=0Aor change any contractual relationship. =0D=0A
fn:Rick Beton
end:vcard