Quick Study Revision Points: Inter-process Communication and Synchronization
Table of contents
Inter-process Communication (IPC):
Definition: Inter-process communication refers to the mechanisms and techniques used by processes to exchange data and synchronize their actions in a multi-process or multi-threaded environment.
Purpose: IPC enables processes to collaborate, coordinate, and share resources effectively, facilitating communication and data sharing between different processes.
IPC Mechanisms: a. Shared Memory: Processes can share a common memory region for direct data exchange. b. Message Passing: Processes communicate by sending and receiving messages through a communication channel. c. Pipes: Unidirectional communication channels that connect the output of one process to the input of another process. d. Sockets: Communication endpoints that enable processes to communicate over a network. e. Signals: Asynchronous notifications sent by one process to another to handle events or exceptions. f. Remote Procedure Call (RPC): Allows processes to invoke procedures or functions in a remote process as if they were local.
Advantages and Disadvantages of IPC Mechanisms: a. Shared Memory:
Advantages: High performance, direct data access, and efficient communication.
Disadvantages: Synchronization and data consistency issues, as shared data can be modified concurrently by multiple processes. b. Message Passing:
Advantages: Simplicity, encapsulation of data, and explicit communication semantics.
Disadvantages: Overhead due to data copying, message passing coordination, and potential blocking. c. Pipes:
Advantages: Simple and efficient for sequential communication between related processes.
Disadvantages: Limited to one-way communication and requires a parent-child relationship between processes. d. Sockets:
Advantages: Versatility, supports communication between processes on different machines, and over different networks.
Disadvantages: Overhead due to network communication and potential security concerns. e. Signals:
Advantages: Asynchronous communication, enables process-to-process event handling.
Disadvantages: Limited data capacity, no guarantee of message delivery, and potential signal handling complexities. f. RPC:
Advantages: Abstraction of network communication, allows remote procedure invocation, and hides network implementation details.
Disadvantages: Network latency, potential for network failures, and additional complexity in handling remote procedures.
Synchronization: a. Mutual Exclusion: Techniques to ensure that only one process can access a shared resource at a time to prevent conflicts and data corruption. b. Semaphores: Counting or binary mechanisms used to control access to shared resources and coordinate process execution. c. Locks: Similar to semaphores, locks provide mutual exclusion but are typically binary in nature. d. Monitors: High-level synchronization constructs that combine data and procedures, providing safe access to shared resources. e. Condition Variables: Used in conjunction with locks to enable processes to wait for specific conditions to be met before proceeding. f. Deadlock: A situation where two or more processes are unable to proceed because each is waiting for a resource held by another process. g. Starvation: A condition where a process is unable to progress because it is constantly being denied access to a resource it needs. h. Concurrency Control: Techniques to ensure consistency and integrity in a multi-process environment, particularly in database systems. i. Critical Sections: Code segments that require mutual exclusion to maintain data consistency. j. Memory Barriers: Instructions or mechanisms used to enforce ordering and visibility of memory operations in a multi-threaded environment. k. Atomic Operations: Operations that are indivisible and cannot be interrupted, ensuring consistency in concurrent execution.