inter process communication ipc - TarisMajor/5143-OpSystems GitHub Wiki

Definition

Inter-Process Communication (IPC) refers to the methods and mechanisms that allow processes to exchange data or synchronize their actions. IPC is vital in systems where multiple processes or threads need to cooperate, share data, or execute in parallel. It allows processes to communicate while ensuring that the system remains stable and that shared resources are accessed correctly. The main IPC mechanisms include Pipes, Message Queues, Shared Memory, and Sockets, each offering different methods for data exchange and synchronization.

Pipes

A pipe is a communication mechanism that allows data to flow in one direction between two processes. It is one of the simplest forms of IPC, where the output of one process becomes the input for another. Pipes are often used for streaming data from one process to another.

Message Queues

A message queue is a queue that holds messages that are sent between processes. Unlike pipes, which work with streams of data, message queues are more flexible and allow for storing messages (or chunks of data) until they can be read by another process. They provide asynchronous communication, meaning the sender does not have to wait for the receiver to acknowledge the message.

Shared Memory

Shared memory allows multiple processes to access the same block of memory, facilitating fast communication and data sharing. A process writes data to a shared memory segment, and other processes can read or modify that data. It is the fastest IPC method because processes do not need to copy data between them, unlike pipes or message queues. However, it requires careful synchronization to prevent data inconsistency.

Sockets

A socket is an endpoint for sending or receiving data across a network. Sockets provide a standardized interface for network communication. They allow processes on different machines to communicate with each other over a network (or even within the same machine). Sockets can be used for both stream-based (TCP) and datagram-based (UDP) communication.

Sources

Tanenbaum, A. S., & Woodhull, D. J. (2009). Operating Systems: Design and Implementation (3rd ed.). Prentice Hall. Stallings, W. (2017). Operating Systems: Internals and Design Principles (9th ed.). Pearson Education. Silberschatz, A., Galvin, P. B., & Gagne, G. (2018). Operating System Concepts (9th ed.). Wiley. Andrew S. Tanenbaum (2007). Modern Operating Systems (3rd ed.). Pearson.