Inter-Process Communication

Inter-Process Communication

Posted on Updated on

Producer-Consumer

clip_image002

• Consumer sends N empty messages (i.e., slots)

• Producer picks up an empty message/slot and send back an item produced

• Consumer receives an item and sends back an empty message (i.e., a slot)

• Messages sent, but not received are buffered by OS

Characteristics

Naming: Direct Communication

• Sender/receiver refer to each other, as seen before

• Properties of communication link

– Link is established automatically between communicating processes

– Link is associated with exactly two processes

–Exactly one link for every pair of processes

• Communication is symmetric(above) or asymmetric

– send(P,m) // send a message to P

– receive(&id, m) // receive from any process, set id to sender

Direct Naming

clip_image004

Naming: Indirect Communication

• Communication via mailboxes (or ports)

• Processes communicate by putting and taking messages in/from mailboxes

–send(A, m)and receive(A,m)

• Properties of communication link

– A link is established between two processes, if they share a mailbox

– Link maybe associated with more than two processes

– A number of different links may exist between any pair of processes; each one a separate mailbox

Indirect Naming

clip_image006

Posted By-: Vissicomp Technology Pvt. Ltd.

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

Advertisements

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