Saturday, July 30, 2011

Inter Process Communication - Basic definition

Inter-process communication (IPC) is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared memory, and remote procedure calls (RPC). The method of IPC used may vary based on the bandwidth and latency of communication between the threads, and the type of data being communicated.

There are several reasons for providing an environment that allows process cooperation:
  • Information sharing
  • Speedup
  • Modularity
  • Convenience
  • Privilege separation
IPC may also be referred to as inter-thread communication and inter-application communication.

IPC Properties

How long and under what conditions an IPC object remains in existence.
  • Process-persistent: exists until last process with IPC object open closes the object. E.g. pipe. 
  • Kernel-persistent: exists until kernel reboots or IPC object is explicitly deleted. E.g. semaphore, shared memory. 
  • Filesystem-persistent: exists in the file system or until IPC object is explicitly  deleted. E.g. shared file, memory mapped shared memory.
Name spaces:
IPC objects can be referred by names or identifiers.
E.g. sockets, pipes and files are identified with file descriptors, which is a systemwide unique non-negative integer.
E.g. semaphore, message queue and shared memory are named with keys and identified by system IDs in their own name spaces.

The same as Unix file access permission, that is, readable, writable, executable for user, group, and others.

Throughput is referred to the bandwidth of the message passing.
E.g. TCP/IP sockets over a 10-Base Ethernet cannot transmit more than 1MB/s.


Latency is referred to the delay incurred when passing a message.
Most IPC communication can be completed in micro-seconds, e.g. semaphore, signal. Some can be done in nano-seconds, e.g. shared memory.


System limits for the number of IPC objects. File descriptor based IPC cannot exceed the total system file descriptors.

Choosing the Right IPC
The decision should be based on:
• Location of the process: Sharing data between processes on the same machine or over the network.
Signal, pipe, shared memory, semaphore, and message queues work for processes on the same machine.
Socket works for both situation.
File and shared memory can work across network providing NFS and special program is running to replicate them.

• Performance requirement and Hardware architecture. E.g. Shared memory is more efficient than other IPC on SMP machines.

• Level of abstraction.
Inter-operability between processes can be achieved by introducing a layer of abstraction, such as CORBA, DCOM and DCE.

The main IPC methods are written below. Follow the each link to get a detailed idea of each of them with the sample working code.

  1. File
  2. SignalPOSIX Signal
  3. Socket
  4. Message Queue
  5. Pipe
  6. Named Pipe
  7. Semaphore
  8. Shared Memory
  9. Message Passing

No comments:

Post a Comment