Inter-Process Communication

Introduction

 
In general, inter-process communication is a mechanism that allows processes to communicate with each other. The IPC methods vary depending on the operating systems we rely on.
 
There are two ways where a process can communicate,
  1. Shared memory
  2. Message passing 

IPC Mechanisms in windows

  1. Clipboard 
  2. Data copy
  3. DDE 
  4. File mapping 
  5. Mail slots 
  6. Pipes 
  7. RPC 
  8. Windows sockets
Selecting the correct IPC that matches your need depends on a few of the following questions,
  • Should the application be able to communicate with other applications running on other computers on a network, or is it sufficient for the application to communicate only with applications on the local computer?
  • Should the application be able to communicate with applications running on other computers that may be running under different operating systems?
  • Should the application communicate with many different applications in a general way, such as allowing cut-and-paste operations with any other application, or should its communications requirements be limited to a restricted set of interactions with specific other applications?
  • Is performance a critical aspect of the application? All IPC mechanisms include some amount of overhead.
  • Should the application be a GUI application or a console application? Some IPC mechanisms require a GUI application.

Key Findings

 
Clipboard
  1. Both the applications should support the clipboard for those data formats that they understand.
  2. For example, a text editor or word processor should at least be able to produce and accept clipboard data in pure text format.
Data copy
  1. Data copy enables an application to send information to another application using the wm_copydata message.
  2. The data sent is read-only for the receiving application. It works only for the processes running on the same computer.
DDE
  1. It sends messages between applications that share data and uses shared memory to exchange data between applications.
  2. Applications can use the DDE protocol for one-time data transfers and for continuous exchanges.
  3. DDE is not as efficient as newer technologies. However, you can still use DDE if other IPC mechanisms are not suitable or if you must interface with an existing application that only supports DDE.
File mapping
  1. Allows one-way and bi-directional communication between applications. It uses shared memory for data sharing.
  2. File mapping can be used only between processes on a local computer; it cannot be used over a network.
  3. Mail slots:
  4. Mail slots provide one-way communication. A process can be both a mail slot server and a mail slot client, so two-way communication is possible using multiple mail slots.
  5. Mail slots offer an easy way for applications to send and receive short messages. They also provide the ability to broadcast messages across all computers in a network domain.
Pipes
  1. Allows two-way communication. Two types of pipes are available. Named and anonymous pipes.
  2. Named pipes are used to transfer data between unrelated process where anonymous is used between processes on a same computer.
RPC
  1. RPC enables applications to call functions remotely. RPC operates between processes on a single computer or on different computers on a network.
  2. Applications that use RPC are able to communicate with applications running with other operating systems that support DCE (Distributed Computer Environment).
Windows Sockets
  1. Windows Sockets (Winsock) enables programmers to create advanced Internet, intranet, and other network-capable applications to transmit application data across the wire, independent of the network protocol being used.
  2. For example: peer to peer such as chat applications / client-server models.

Conclusion

 
The selection of an IPC completely depends on the process specifications. In general, shared memory will perform faster than the message passing because in shared memory it relies only a single time on the kernel for memory creation but in message passing It is time consuming as it is implemented through kernel intervention.
Each has its own pros and cons like shared memory can be used for local process and message passing can be used for remote process, etc.
 
Sharing the detailed benchmark of different IPC’s - IPC Benchmarks


Recommended Free Ebook
Similar Articles