EmbeddedSoftware6
EmbeddedSoftware6
• Types of IPC
• Message passing
• Shared memory
• Message passing
• Blocking/non-blocking, …
• Datagrams, virtual circuits, streams
• Remote procedure calls
MESSAGE PASSING (I)
send(…)
receive(…)
ADVANTAGES
• Very general
• Sender and receivers can be on different machines
• Relatively secure
• Receiver can inspect the messages it has received
before processing them
DISADVANTAGES
• Hard to use
• Every data transfer requires a send() and a
receive()
• Receiving process must expect the send()
• Might require forking a special thread
SHARED MEMORY
• Name says it
• Two or more processes share a part of their address
space
Process P
shared
Process Q
ADVANTAGES
• Defining issues
• Direct/Indirect communication
• Blocking/Non-blocking primitives
• Exception handling
• Quality of service
• Unreliable/reliable datagrams
• Virtual circuits, streams
DIRECT COMMUNICATION (I)
• Mailboxes can be
• Private
• Attached to a specific process
• Think of your cell phone
• Public
• System objects
• Think of a house phone
PRIVATE MAILBOXES
• Process that requested its creation and its children are the
only processes that can receive messages through the
mailbox are that process and its children
• Cease to exist when the process that requested its creation
(and all its children) terminates.
• Often called ports
• Example: BSD sockets
PUBLIC MAILBOXES
receive(…)
acts as a
retrieve(…)
Buffer
msg
SIMULATING BLOCKING RECEIVES
do {
code = receive(mbox,msg,size);
sleep(1); // delay
} while (code == EMPTY_MBOX);
• Datagrams:
• Messages are send one at time
• Virtual circuits:
• Ordered sequence of messages
• Connection-oriented service
• Streams:
• Ordered sequence of bytes
• Message boundaries are ignored
DATAGRAMS
send_req(args); rcv_req(&args);
process(args, &results);
send_reply(results);
rcv_reply(&results);
MOTIVATION (II)
• We could write
rpc(xyz, args, &results); xyz(...) {
...
return;
... } // xyz