Message Passing - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Message Passing

Description:

Synchronized message passing. Guarded selection (based on Dijkstra's guarded ... An OCCAM program consists of processes that communicate using message passing ... – PowerPoint PPT presentation

Number of Views:181
Avg rating:3.0/5.0
Slides: 20
Provided by: scie251
Category:
Tags: message | passing

less

Transcript and Presenter's Notes

Title: Message Passing


1
Message Passing
  • All of the synchronization techniques so far work
    only if shared memory is available
  • Two techniques that can be used in distributed
    memory systems
  • Remote Procedure Calls
  • Message Passing

2
Remote Procedure Calls
  • Introduced in 1984

3
Remote Procedure Calls
  • Language neutral
  • Based on the semantics of procedure calls
  • Issues
  • Finding procedures (services)
  • Data representation

4
Message Passing
  • Another synchronization tool is message passing
  • Basic idea is that sender and receiver must be
    ready to communicate
  • Only two basic operations
  • Send( receiver, message )
  • Receive( sender, message )
  • Systems differ on how the sender and receiver
    find each other

5
OCCAM 2
  • Based on C.A.R. Hoares CSP (Communicating
    Sequential Processes)
  • Named for William of Occam, 14th century English
    philosopher
  • Do not do with more, what you can do for less
  • Includes
  • Parallel Processes
  • Synchronized message passing
  • Guarded selection (based on Dijkstras guarded
    command)

6
OCCAM 2
  • Developed by Sir David May at INMOS in England
  • An OCCAM program consists of processes that
    communicate using message passing
  • A well behaved OCCAM program will eventually
    terminate
  • You do not want your OCCAM program to STOP

7
OCCAM Types
  • Primitive types
  • INT, REAL, BOOL
  • INT16, INT32, INT64,
  • BYTE
  • CHANNEL
  • TIMER
  • Arrays
  • 1000 REAL64 amplitude

8
Literals
  • Integer, byte, and string literals are the usual
  • Hexadecimal numbers are preceded with a
  • Boolean literals are TRUE and FALSE
  • Reals numbers
  • You must specify the type 7.234(REAL32)
  • You cannot omit the decimal
  • There must be one digit before the decimal
  • No signed literals!!

9
Expressions
  • Essentially what you would expect, but
  • There is only one precedence level in OCCAM
  • Comparisons , ltgt, lt, gt, and gt
  • Arithmetic operations are not defined for bytes
  • Booleans AND, OR, /\, \/, gtlt
  • Logical shift ltlt and gtgt

10
Basic OCCAM Processes
  • Assignment
  • Variable Expression
  • Send
  • Channel ! Expression
  • Receive
  • Channel ? Variable
  • SKIP
  • STOP

11
OCCAM Constructors
  • SEQ executes statements in sequence
  • SEQ
  • Statement 1
  • Statement 2
  • A SEQ terminates when its last component
    terminates
  • A SEQ with no components is the same as a SKIP

12
Conditional
  • The conditional is familiar, the syntax is
    different
  • IF
  • I lt 0
  • p I 100
  • I 0
  • p 200
  • I lt 0
  • p I

13
Conditional
  • Booleans are execute in sequence until one
    evaluates to true
  • The IF terminates when the process following the
    boolean terminates
  • The IF does not terminate if none of the boolean
    expressions evaluate to TRUE

14
Channels
  • Channels can be used to connect processes
  • Data flows in one direction only
  • Although most implementation allow bi-directional
    communication
  • Channels are typed
  • Channels are not buffered
  • Communication does not take place until both
    processes are ready

15
PAR
  • A PAR executes processes in parallel
  • PAR
  • process1
  • process2
  • A PAR terminates when all of its processes
    terminate

16
Examples
  • Pipeline
  • PipeSort
  • Hypercube routing

17
ALT
  • Basically provides a way to poll channels for
    messages without blocking

ALT up ? increment x x increment
down ? decrement x x decrement read ?
request reply ! x
18
A Simple Pipeline
PROC pipeline (CHAN OF BYTE stdin, stdout,
stderr) 15 CHAN OF BYTE chan VAL BYTE
end.char IS '!' PROC filter (CHAN OF BYTE
in, out) BYTE num SEQ num0
WHILE numltgtend.char SEQ in ?
num out ! num PROC generate
(VAL BYTE beg, end, CHAN OF BYTE out) BYTE
num SEQ numbeg WHILE numltend
SEQ out ! num
numnum1 out ! end.char
PROC display (CHAN OF BYTE in, out) BYTE
num SEQ WHILE numltgtend.char
SEQ in ? num out ! num
out ! 'n' PAR generate('A','z',ch
an0) PAR i0 FOR 14
filter(chani,chani1) display(chan14,std
out)
19
Pipesort
PROC pipesort (CHAN OF BYTE stdin, stdout,
stderr) INCLUDE "consts.occ" INCLUDE
"utils.occ" VAL INT num IS 10 num1 CHAN
OF INT chan VAL INT end.number IS -1
PROC filter (CHAN OF INT in, out) INT
mynum,num SEQ in ? mynum WHILE
mynumltgtend.number SEQ in ? num
IF numltmynum
num,mynummynum,num TRUE
SKIP out ! num out ! mynum

PROC display (CHAN OF INT in, CHAN OF BYTE
out) INT num SEQ WHILE
numltgtend.number SEQ in ? num
out.number(num,5,out) out !
'n' PAR random(123,num,chan0)
PAR i0 FOR num filter(chani,chani1)
display(channum,stdout)
Write a Comment
User Comments (0)
About PowerShow.com