CHPT 3 Part 2
CHPT 3 Part 2
CS2006
Chapter:3
Inter-Process Communication (IPC)
Part:2
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
This scheme allows at most BUFFER SIZE − 1 items in the buffer at the same
time.
Message Passing
(IPC)
Message system – processes communicatewith
each other without resorting to shared variables.
IPC facility provides two operations:
send(message) – message size fixed or variable
receive(message)
If P and Q wish to communicate, they need to:
establish a communication link between them
exchange messages via send/receive
Implementation of communication link
physical (i.e., shared memory, hardware bus)
logical (direct/ indirect, blocking/ non-blocking,
automatic/ explicit buffering)
write() read()
if (pipe(pfds) == -1)
{
perror("pipe") pfds[0]
} ; exit(1); } pfds[1]
Process
Kernel
Pipe
flow of data
int write(int
filedescriptor,char
*buffer,int bytetowrite);
pfds[1]);
A Channel between two
processes
Parent Child
2. Fork()
pfds[0] pfds[0]
pfds[1] pfds[1]
1. Pipe()
Process
Kernel
Pipe
flow of data
Pipe
flow of data