Interprocess Communication is a way through which processes communicate with each other. Interprocess Communication is only required by cooperating processes because they affects the other processes.
Processes communicates with each other using 2 ways:
- Shared Memory : In this model there is a part of memory which is shared by processes. Processes are able to share information with the help of these shared regions. Lets suppose there are 2 processes in the memory A and B. A wants to share some information with B. Then A can write that information in the shared memory and B can read from that region.
- Message Passing : In this model of process communication the processes directly communicate with each other by exchange of messages. This approach is implemented by using system calls so it takes more time to execute than shared memory.
There are other methods of IPC too. Let's discuss about them one by one.
3. Pipes : Pipes is another technique of passing information. But pipes can only be used to send information in one direction only (unless you don't use double pipes). In pipes the output of a process is passed over to another process which serves as an input to that process.
4. Message Queues : It refers to a list of messages stored in the kernel. Each list is identified by its message queue identifier. In this approach there is bidirectional flow of information.
5. Direct Communication : In this approach each process has to explicitly mention the name of sender of communication.
6. Indirect Communication : In this approach messages are send and received through mailboxes. A mailbox is an object that stores the messages from different process.
Why IPC:
- IPC is needed to speedup modularity.
- IPC helps processes to communicate with each other.
- Provides computational benefits.