Interprocess Communications
Interprocess Communications
Processes
• Cooperating Processes
• Interprocess Communication
Interprocess Communication
• Processes within a system may be independent or
cooperating
• Independent process cannot affect or be affected by the
execution of another process
• Cooperating process can affect or be affected by the
execution of another process
• Advantages of process cooperation
– Information sharing
– Computation speed-up
– Modularity
– Convenience
Cooperating Processes
• Cooperating processes need inter process communication
(IPC)
Shared data
#define BUFFER_SIZE 10
typedef struct {
...
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
Solution is correct, but can only use BUFFER_SIZE-1
elements
Bounded-Buffer – Producer
while (true) {
/* Produce an item */
while (((in = (in + 1) % BUFFER SIZE) == out)
; /* do nothing -- no free buffers */
buffer[in] = item;
in = (in + 1) % BUFFER SIZE;
}
Bounded Buffer – Consumer
while (true) {
while (in == out)
; // do nothing -- nothing to consume
• Sockets
• Remote Procedure Calls
• Pipes
• Remote Method Invocation (Java)