Buffering

Inter-Process Communication

Posted on Updated on

Mailboxes

It depends:

• At most one process may execute a receive operation at a time

• The system arbitrarily selects one as the receiver

• Message is retrieved by both (a form of multicast)

Ownership

• Either process can own the mailbox

• OS can own it and/or creator owns it

clip_image002

Sender/Receiver Synchronization

• Message passing maybe blocking or non-blocking

(synchronous or asynchronous)

• Blocking send– sender blocked until message is received by receiver (or by mailbox)

• Non-blocking send– sending process resumes operation right after sending

• Blocking receive– receiver blocks until message is available

• Non-blocking receive– receiver retrieves a valid message or returns an error code

• Any combination of the above send/receive is possible

Blocking vs. non-blocking send

clip_image004

Buffering

• The mechanism that buffers messages (a.k.a.queue) may have the following properties

–Zero capacity: queue has length 0, no messages can be outstanding on link, sender blocks for message exchange

–Bounded capacity: queue has length N, N messages can be in queue at any point in time, sender blocks if queue is full, otherwise it may continue to execute

–Unbounded capacity: queue has infinite length, sender never blocks

Message Passing in Practise

• Message Passing Interface (MPI) used in parallel programming systems

• Open MPI, a standard

• Unix’s IPC – Inter-process communication facilities

– Semaphores

– Pipes, FIFO

– Message queues

–Sockets

– Shared memory, memory mapped files

Characteristics of Message Passing

• Addressing

– Each process has a unique name

– Introduce the concept of a mailbox

• With sender, with receiver, with both, with OS

• Buffering

– No buffering, send blocks until receive happens or vice versa, then copy message (called a rendezvous)

Copy-on-write

• Message passing for process-to-process communication can be quite inefficient due to context switching etc.

• Copy-on-write first sets a pointer in receivers address space pointing to received data in sender’s address space

• Only if sender / receiver start writing this data will the OS copy the actual data from sender to receiver

• Otherwise, no copying of the data is performed

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Advertisements