Communication Between Processes

Processes operate within their own virtual address space and are protected by the operating system from interference by other processes. By default a user process cannot communicate with another process unless it makes use of secure, kernel managed mechanisms. There are many times when processes will need to share common resources or synchronise their actions. One possibility is to use threads, which by definition can share memory within a process. This option is not always possible (or wise) due to the many disadvantages which can be experienced with threads. Methods of passing messages or data between processes are therefore required.

Linux supports the following methods of communication. System V IPC refers to the version of Unix in which the concepts noted below were first introduced.

Signals | Signals are used to signal asynchronous events between processes. A process may implement a signal handler to carry out required when an event occurs or may use the system default actions. Most signals can be ignored or blocked, though the KILL signal cannot be ignored and will result in a non clean process exit.
UNIX pipes | A pipe connects the standard output of one process to the standard input of another. They provide a method of one-way communication between processes in a parent-child relationship and for this reason may be called half duplex pipes.
Named Pipes (FIFOs) | Named pipes appear similar to regular pipes but are implemented as device special First In-First Out (FIFO) files in the file system. It is not necessary for processes to maintain a parent-child relationship for them to communicate via named pipes. Named pipes are persistent and may be reused after their initial setup.
System V IPC Message Queues | Message queues consist of a linked list within the kernel's addressing space. Messages are added to the queue sequentially and may be retrieved from the queue in several different ways.
System V IPC Semaphores | Semaphores are counters used to control access to shared resources by multiple processes. They are most often used as a locking mechanism to prevent processes from accessing a particular resource while another process is performing operations on it. Semaphores are implemented as sets, though a set may have a single member.
System V IPC Shared Memory | Shared memory is a mapping of an area of memory into the address space of more than one process. This is the fastest form of IPC as processes do not subsequently need access to kernel services in order to share data.
Full-duplex pipes (STREAMS) | STREAMS were introduced by AT&T and are used for character based I/O within the kernel and between it?s associated device drivers as a full duplex transfer path between processes. Internally pipes may be implemented as STREAMS.
Remote Procedure Call (RPC) | A network inter-process connection protocol based on Sun Microsystems' RPC standard.
Networking sockets (Berkeley style) | Sockets allow local or network connection between processes. Socket names are implemented within a domain. In the UNIX domain a socket is given a path name within the file system. Other processes may use that name to communicate.

Windows NT inter-process communication and synchronisation facilities include the following :

Events or Event Pairs | Event handles may be inherited, passed on creation or duplicated for a process. Event handles may optionally have names and are signalled using the SetEvent call.
Anonymous Pipes | Used primarily for communication between related processes. Anonymous pipes cannot be used over a network.
Named Pipes (FIFOs) | Named pipes are similar to anonymous pipes but may be referenced by name rather than handle, may be used over a network and can use asynchronous, overlapped I/O.
Semaphores | Like Linux, Windows NT semaphore objects are implemented as counters which act as guardians over a section of code or resource.
Shared Memory | A section object is a Win32 subsystem object which is made available as a file mapping object which two or more processes may share. One thread creates the section object and other threads obtain handles to it.
Remote Procedure Calls (RPCs) | An implementation of the Distributed Computing Environment (DCE) standard for calling processes over a network.

Local Procedure Calls (LPCs)

A facility similar in usage to RPC but in fact being a cut down version that can act only on a local computer to perform efficient message passing between client/server processes using kernel provided mechanisms. There are three basic choices :

1. Messages may be passed into a server port objects message queue - used for small messages.
2. Messages are passed via a shared memory object.
3. Quick LPC is used by portions of the Win32 subsystem to achieve minimum overhead and maximum speed.

STREAMS | An implementation of the Unix System V driver environment used in networking.