In modern computer systems, the concept of a process (a program in execution) is used to perform multiple tasks at the same time. And since multiple processes running on a single or multiple computers at the same time are connected to a network can exchange the data/information through a process called inter-process communication (IPC). This article gives a brief description of inter-process communication between the processes.
Definition of Inter-Process Communication:
Inter-process communication is a mechanism provided by the OS for communications between several processes. It is simply called IPC in short. It is used to exchange the data/information between single or multiple processes and can be controlled by some control mechanisms and a communication process.
IPC can also be stated as a mechanism provided by the operating system for processes to manage shared data. In general, applications that use IPC are classified as clients and servers, where the data requested by the client and server responds to the client’s request. Most of the applications are clients and servers commonly observed in distributed computing.
In IPC, the different types of processes running on the OS can connect to different types of operations to the OS. It is used between different types of operations involving computers and operating systems. Processes running at the same time in the OS can be either independent processes or shared processes. In this, the processes can communicate with each other and their actions are synchronized.
Inter-Process Communication Diagram:
Operating systems provide communication between processes so that information can be exchanged between processes is called inter-process communication (IPC). It allows programmers to coordinate actions between multiple processes running on the system at the same time. There are two types of processes in the system Independent process and the Cooperative process.
Independent process: An independent process is a process that does not affect or is not affected by other processes running on the system. In simple words, any process that doesn’t share data with other processes.
Cooperative process: It is when it affects or can be affected by other processes running on the system. A process that communicates with other processes can exchange the data. Inter-process communication comes under cooperating process because it can provide information sharing, computational speed, modularity, and ease of data access.
The basic inter-process communication diagram is shown in the figure below.
From the above diagram, Inter-Process Communication (IPC) mechanism allows the data to be exchanged between processes. It uses either shared memory or a memory mapping mechanism. This allows resources and data to be shared between processes without interference. Processes running at the same time in the OS can be either co-operating processes or independent processes. If the processes are independent, then they may or may not be affected by other processes running on the system and don’t share the data with other processes.
Assume that processes running together can be influenced by other processes running on the system. In this case, any process that communicates with other processes can share the data and the memory. For example, if process 1 sends the message, then process 2 receives the message sent by the process. Therefore, process 1 acts as the sender, and process 2 acts as the receiver.
IPC is very important in the process of designing an OS kernel, which is small to reduce the number of functions provided by the kernel. These capabilities can be obtained by communicating with the server via IPC, which greatly improves communication over simpler OS kernel types that provide more functionality.
How Does Inter-Process Communication Work ?
As we discussed now, a process is divided into 2 types, such as independent process and co-operating process. Inter-process communication is a co-operating process because the processes communicate with each other with synchronization. That means, one process can share the data with the other process, increasing the communication speed, and modularity and very easy to access the data by the process.
The different inter-process communication types are:
In this method, the multiple processes can communicate with each other simultaneously by accessing or sharing the memory. The multiple processes can exchange the data using read/write to the shared memory because the OS creates a common memory in RAM for sharing. It requires protection by the synchronization of access of all multiple processes in the communication.
It is a more efficient method and shares the data very quickly. To understand this, consider the 2 processes as process 1 and process 2. If one process creates memory, then the other process will access it by means of sharing. The communication between the processes in IPC using the shared memory method is shown in the figure below.
The information generated by process 1 about a particular resource and stored the record in shared memory. If process 2 wants to use this information, it checks the stored record in the shared memory, takes the information generated by process 1, and processes it accordingly. Thus, processes 1 and 2 can utilize shared memory to retrieve information such as records from other processes and transfer certain information to other processes. Examples are Posix and Windows operating systems.
- The communication process is very fast and bidirectional.
- Multiple processes can use the shared memory.
- Resources are saved.
- Required concurrency control.
- No protection of data.
- Inconsistency of data occurred as updates were lost.
It is the other method of inter-process communication for synchronization and communication between the processes. It is very slow and easy to implement using system calls compared to the shared memory method. The processes can exchange the data with each other without using any shared resources or variables.
In message passing, the communication between the processes is performed through the communication link. The operations performed by the processes are, sending the message and receiving the message. Since the message might be variable or fixed type.
From the above figure, process 1 sends (writes) the message (M) to the kernel. While process 2 receives (reads) the message from the kernel sent by process 1.
Suppose, process 1 and process 2 communicated together by establishing the communication link as shown in the figure above. After that, they exchange the message through send and receive operations. The message is transferred in the First In First Out (FIFO) style. The standard message exchanged by the processes contains 2 parts. Such as
Header: It contains the type of message, source and destination identities, length of the message, and control information like priority, sequence number, and low disk space actions.
Body: It contains the original message that is to be exchanged.
The communication link can be established in different types. They are,
- Direct communication.
- Indirect communication.
- Synchronous message passing.
- Asynchronous message passing.
Advantage: Very easy to implement.
Disadvantage: Communication is slow because it takes time to set up communication links or connections between the processes.
It is a one-way communication or half-duplex communication mode in IPC. It is the most widely used IPC for communication between the two processes. If one process writes/sends the data, then the other process will receive or read it. Pipes are created using a pipe system called. For example, filling the water into a bucket with a tap. The pipes are used in Posix and various windows OS versions.
This type of IPC provides communication between single or multiple processes in full-duplex mode. It is a linked messages list stored in a kernel of an operating system. And the stored messages are recognized and identified by the message queue identifier.
The messages are coordinated by the Application Program Interface(API). Several messages can read and write data to and from the message queue. A message queue is where messages are stored or queued until the recipient retrieves them. It is used in IPS and all operating systems.
It is First-In-First-Out inter-process communication. It is a kind of mutual communication between two independent processes. It can also be called a full-duplex. That is, one process can interact with another process and vice versa. It is similar to the pipes.
This type of IPC creates or establishes a connection or communication link between two communication processes. However, each pair of communication processes can have only one connection. It is a unidirectional and bidirectional communication process. The communication between the processes is either symmetric addressing type or asymmetric addressing type.
If the receiver process knows the sender’s process identity, then it is called a symmetric addressing type of direct communication. If the sender specifies the name of the receiver to send the message, then it is called an asymmetric (asynchronous) addressing type of direct communication.
This type of IPC can exist or be created when processes share the same mailbox and each pair of those processes share multiple communication channels or links. These shared links can be one-way or two-way. When process 1 sends the data to the mailbox, then process 2 at the receiver retrieves the data from the mailbox. One to one, one to many, many to one and many to many communication links can be formed through a common mailbox.
It is an extension for direct and indirect communication with additional synchronization options as needed. Processes can be blocked while sending or receiving messages. It can also communicate asynchronously without blocking. Mutual exclusion, semaphores, spinlock, and barrier are the methods to provide synchronization in IPC.
Memory-mapped process communication uses shared memory or files to be shared between different processors. The memory mapping mechanism increases the speed of file access and provides IPC.
The socket communication process is used over a network between a client and a server. The socket method provides a standard connection, independent of the type of OS and computer used. It works as an endpoint for sending and receiving the data on the network.
This is used to resolve synchronization issues and prevent race conditions. They are integers greater than or equal to zero.
It is referred to as a stored document or data record and can be obtained or received by the file server. The file can be accessed by several processes if necessary.
Difference Between Synchronous and Asynchronous Inter-Process Communication
The differences between synchronous and asynchronous inter-process communication are given in the table below.
|S. No||Synchronous Inter-Process Communication||
Asynchronous Inter-Process communication
|1||It is also known as blocking inter-process communication in both send and receive modes.||It is also known as non-blocking inter-process communication in both send and receive modes.|
|2||Blocking send mode: The sending process is blocked until the message is received by the receiving process.||Non-block send mode: The message will be sent by the sending process and resumes the operation. It doesn’t matter whether the receiver exists or not.|
|3||Blocking receive mode: In this, the receiver can block the available message and will not continue the process until the sending process exists.||Non-blocking receive mode: The receiver doesn’t wait for the sender to send the message or data and continues the process. It receives either a NULL message or a valid transmitted message by the sender.|
|4||This communication occurs between various processes running at the same time.||In this communication, a process that receives asynchronous messages may or may not be used by the process it is trying to send a message to.|
Examples Of Inter-Process Communication
The examples of inter-process communication are,
- Posix utilizes the shared memory technique in inter-process communication
- Mach and Windows XP utilize a message passing technique.
- Pipes and servers.
The following are the advantages of inter-process communication.
- It helps to share the same data or information between the multiple processes and perform various tasks. In this, the process requires access to the remote process.
- The different processes can share the resources to provide communication between them.
- It increases the computational speed during communication between the processes.
- It enhances efficiency because the construction is divided into various modules. Where these modules cooperate using IPS.
- Privilege separation.
- It helps the processes and OS to communicate with each other with synchronization.
- The communication is bidirectional.
- Allows control of one application with another application.
- Enables data sharing without any interference.
The disadvantages of inter-process communication are,
- In message-passing IPC, a small amount of data is exchanged between the processes.
- The processes should not write to the same memory location while using a shared-memory method.
- Synchronization issues.
- Data protection issues.
- Data accessing issues.
- It doesn’t work on multiple machines at the same time.
Inter-Process Communication Applications
Inter-process communication applications are listed below.
It is used in remote procedure call interfaces such as RMI (remote method innovation) of Java, ONC RPC, JSON RPC, dot net remoting, message bus, XML RPC, RPC, etc.
Used in platform communication stack messaging and data systems such as desktop communication protocol of KDE, D-bus, multicore communication API, SIMPL (synchronous inter-process messaging in Linux), 9P (file system protocol plan 9), Openwrt, DCE (distributed computing environment), ICE (internet communications engine), Thrift, MQ, Enduro/X middleware, Enlightenment_software, etc.
Used in distributed projects models like PHP, Distributed Rubey, Electron’s synchronous, C++, and CORBA (common object request broker architecture).
Used in operating system communication stacks like inter-application communications (IAC) for Apple computers, ARexx ports, Mach ports in Mach kernel, DSP and general-purpose processors, COM (component object model), DCOM (distributed component object model), Microsoft transaction server, DDE (dynamic data exchange), OLE (object linking and embedding), local procedure calls, mailslots, Windows communication foundation, anonymous and named pipes, Posix, message queues, shared memory, semaphores, RISC, TIPC (transparent IPC of Linux, open binder) etc.
1). What are the operations performed in IPC?
There are 4 operations performed in IPC to exchange the data between the processes.
2). What are the IPC implementations?
RPC (Remote Procedure Call).
Serial or Parallel communication.
Winsock, UNIX socket API.
3). What are the issues that arise in IPC?
- Ensure how one process communicates with another process to share information without any interference between them.
- Ensure the correct sequence of information is shared or exchanged between the processes.
4). What is the purpose of IPC?
It provides communication between single or multiple processes or programs with synchronization.
Please refer to this article for Inter-Process Communication MCQs
Thus, this is all about an overview of Inter-Process Communication. It can also provide communication between the processes through signaling. That means, the process at the source sends the signal while the process at the destination receives the signal and operates it accordingly.