0% found this document useful (0 votes)
14 views7 pages

3 4 Interprocess Communication

Processes can communicate through either shared memory or message passing. Shared memory allows processes to directly read and write to the same memory blocks, while message passing involves processes explicitly sending messages to each other through communication links. The document provides examples of the producer-consumer problem to illustrate how shared memory and message passing can be used for inter-process communication.

Uploaded by

samislam123sa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

3 4 Interprocess Communication

Processes can communicate through either shared memory or message passing. Shared memory allows processes to directly read and write to the same memory blocks, while message passing involves processes explicitly sending messages to each other through communication links. The document provides examples of the producer-consumer problem to illustrate how shared memory and message passing can be used for inter-process communication.

Uploaded by

samislam123sa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Inter Process

Communication
Processes in the system
Processes running concurrently may be -
Independent (cannot affect or be affected by other process)
Or
Cooperating (can affect or be affected by other process)

Process cooperation is needed for -


➔ Information sharing
➔ Computational speedup
➔ Modularity
➔ Convenience
Inter Process Communication
IPC is a mechanism to exchange data and information among processes.
Two fundamental model of IPC -

1. Shared Memory
2. Message Passing
Shared Memory System
(Producer-Consumer Problem)

Producer: produces products for consumer

Consumer: consumes products provided by producer

Produce Consume
Share Space /
Buffer
Producer Consumer
Producer-Consumer Problem (Producer)

in: next free position in buffer


out: first full position in buffer

Both initialized with 0.

in = 0
out = 0

Here, BUFFER_SIZE = 7

When buffer is full, When buffer is not full,


in = 6 , out = 0 In = 5, out = 0

[0] [1] [2] [3] [4] [5] [6] [0] [1] [2] [3] [4] [5] [6]
Producer-Consumer Problem (Consumer)

in: next free position in buffer


out: first full position in buffer

Both initialized with 0.

in = 0
out = 0

Here, BUFFER_SIZE = 7
When buffer is not empty,
When buffer is empty,
In = 5, out = 0
in = 0 , out = 0

[0] [1] [2] [3] [4] [5] [6] [0] [1] [2] [3] [4] [5] [6]
Message Passing System
If processes P and Q want to communicate, they must send messages to and receive messages
from each other.

A communication link must exist between P and Q.

send(message)

P M1 M2 M3 M4 Q

receive(message)

● Useful for exchanging small amount of data


● More suited for distributed systems than shared memory

You might also like