Lecture 09 Message Passing - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Lecture 09 Message Passing

Description:

The send primitive includes a specific identifier of the destination process. send(P,message) ... explicitly designate a sending process. receive(Q,message) ... – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 12
Provided by: eam80
Category:

less

Transcript and Presenter's Notes

Title: Lecture 09 Message Passing


1
Lecture 09Message Passing
2
Requirements to be satisfied
  • Synchronization
  • Process need to be synchronized to enforce mutual
    exclusion
  • Communication
  • Cooperating processes may need to exchange
    information
  • Solutions
  • Shared memory communication scheme
  • Message passing communication scheme

3
Operations Needed
  • send(destination, message)
  • A process send information in the form of a
    message to another process designated by a
    destination
  • receive(source, message)
  • A process receives information by executing the
    receive primitive, indicating the source of the
    sending process and the message

4
Message Size
  • Fixed size
  • Physical implementation straightforward
  • Difficult programming
  • Variable size
  • More complex physical implementation
  • The programming task becomes simpler

5
Message Buffering
  • When a process sends a message to another
    process, is it copied into the receivers memory
    or in a buffer in between?
  • No buffer
  • The processes must be synchronized for a message
    transfer to take place (rendezvous)
  • Bounded buffer
  • The buffer has finite length N thus, at most N
    messages can reside in it
  • Unbounded buffer
  • Any number of messages can wait in the buffer.
    The sender is never delayed.

6
Synchronization
7
Direct Addressing
  • The send primitive includes a specific identifier
    of the destination process
  • send(P,message)
  • The receive primitive
  • The process explicitly designate a sending
    process
  • receive(Q,message)
  • Receive a message from any process
  • receive(id-variable,message)

8
Indirect Addressing
  • The relationship between senders and receivers
    can be
  • one to one
  • many to one (useful for client/server
    interaction, the mailbox is referred as a port)
  • one to many (useful for applications where a
    message is to be broadcast to a set of processes)
  • many to many

9
Bounded-buffer producer/consumer problem I
  • const
  • capacity / buffering capacity /
  • null / empty message /
  • var i integer
  • ...
  • create_mailbox(mayproduce)
  • create_mailbox(mayconsume)
  • for i 1 to capacity do send(mayproduce,null)
  • parbegin producer consumer parend

10
Bounded-buffer producer/consumer problem II
  • procedure producer
  • var pmsg message
  • while true do
  • receive(mayproduce,pmsg)
  • pmsg produce
  • send(mayconsume,pmsg)

11
Bounded-buffer producer/consumer problem III
  • procedure consumer
  • var cmsg message
  • while true do
  • receive(mayproduce,cmsg)
  • consume(cmsg)
  • send(mayconsume,null)
Write a Comment
User Comments (0)
About PowerShow.com