Process that coexist on the memory at a given time are called concurrent process. The concurrent process may either be independent or cooperating. \
The independent process, as the name implies do not share any kind of information or data with each other. They just compete with each other for resources like CPU, I/O devices etc. that are required to accomplish their task.
The cooperating processes on other hand share, need to exchange data or information with each other. The cooperating processes require some mechanism to exchange data or pass information to each other. One such mechanism is inter-process communication (IPC).
Inter Process Communication (IPC) refers to a mechanism, where the operating systems allow various processes to communicate with each other. This involves synchronizing their actions and managing shared data.
There are three issues here.
- How one process can pass information to another?
- The second has to do with making sure two or more processes do not get in each other’s way, for example, two processes in an airline reservation system each trying to grab the last seat on a plane for a different customer.
- The third concerns proper sequencing when dependencies are present: if process A produces data and process B prints them, B has to wait until A has produced some data before starting to print.
IPC allows the processes running on the single system to communicate with other. Two basic communication model for providing IPC are:
- Shared Memory
- Message Passing
1. Shared Memory
Communication between processes using shared memory requires processes to share some variable and it completely depends on how programmer will implement it. One way of communication using shared memory can be imagined like this:
Suppose process1 and process2 are executing simultaneously and they share some resources or use some information from other process, process1 generate information about certain computations or resources being used and keeps it as a record in shared memory.
When process2 need to use the shared information, it will check in the record stored in shared memory and take note of the information generated by process1 and act accordingly. Processes can use shared memory for extracting information as a record from other process as well as for delivering any specific information to other process.
2. Message Passing
In this method, processes communicate with each other without using any kind of of shared memory. If two processes p1 and p2 want to communicate with each other, they proceed as follow:
- Establish a communication link (if a link already exists, no need to establish it again)
- Start exchanging messages using basic primitives.
We need at least two primitives:
- send(message, destinaion) or send(message)
- receive(message, host) or receive(message)