OS Chapter 3 - C Interprocess Communication
OS Chapter 3 - C Interprocess Communication
Operations
create a new mailbox (port)
send and receive messages through mailbox
destroy a mailbox
Primitives are defined as:
send(A, message) – send a message to
mailbox A
receive(A, message) – receive a message
from mailbox A
Indirect Communication
Mailbox sharing
P1, P2, and P3 share mailbox A
P1, sends; P2 and P3 receive
Who gets the message?
Solutions
Allow a link to be associated with at most two
processes
Allow only one process at a time to execute a
receive operation
Allow the system to select arbitrarily the receiver.
Sender is notified who the receiver was.
Synchronization
Network
Logical:
Direct or indirect
Synchronous or asynchronous
Automatic or explicit buffering
Shared Memory
Shared Memory
•Shared memory is a piece of memory space that
does not belong to any particular user process.
Process 1 Process 2
READ
Shared Memory
Shared Memory
Property of Shared Memory No limitation in “direction”
OS
Allocate/Manage
READ
WRITE
Process 1 Process 2
WRITE
READ
Shared Memory
Shared Memory
Property of Shared Memory No protection from “Race Condition”
READ WRITE
Process 1 Process 2
WRITE READ
Shared Memory
Shared Memory
Application Example
Shared Memory
Remote
Client 1
Client 1
Writer Client 2
Process
12:59:59 Remote
Client n Client 2
Time
Keeper
(Delta Time)
OS