🔄

Understanding Interprocess Communication (IPC)

May 23, 2025

Lecture Notes: Interprocess Communication (IPC)

Introduction

  • Topic: Interprocess Communication (IPC)
  • Context: Discuss how isolated processes can interact with each other.

Key Concepts

  • Process: More than executable code; includes CPU state, memory region, open files, and IO devices.
  • Isolation: Processes are isolated by default for safety, but this can hinder cooperation.

Classification of Processes

  • Independent Processes: Do not cooperate with other processes.
  • Cooperating Processes: Share data and need to coordinate activities.
    • Benefits include computational speedup and modularity.

Interprocess Communication Models

  1. Shared Memory

    • Allows processes to share a memory space directly.
    • Privilege Instructions: Enforce isolation by preventing access to other processes' memory.
    • System calls create and attach shared memory regions.
    • Processes manage data structure within shared memory, leading to potential issues like race conditions.
  2. Message Passing

    • Alternately allows processes to communicate without sharing address space.
    • Involves sending messages through mechanisms like pipes, sockets, and remote procedure calls.
    • Requires system calls for send and receive operations.
    • Mailbox/Queue: Used by the OS kernel to handle message storage and delivery.

Examples of Shared Memory Use

  • Chromium Browser: Uses shared memory for modular tasks in browser, renderer, and plugin processes.
  • Other Applications: Include simulation software, game engines, DBMS, and deep learning frameworks.

Examples of Message Passing Use

  • Socket Interface: Common in client-server architecture for processes on the same or different machines.
    • Ports/Listening Ports: Used to establish communication links.
    • Processes communicate through ports, not directly.

Advantages and Disadvantages

  • Shared Memory
    • Faster communication as it allows direct memory access.
    • Requires careful management to avoid conflicts and race conditions.
  • Message Passing
    • Easier for isolated address spaces and remote communication.
    • More complex implementation; system calls are costly.

Conclusion

  • Message Passing vs. Shared Memory: Message passing is generally sufficient despite being slower.
  • Encouragement to explore further and support through links (e.g., codec Crafters).

Final Note

  • IPC is crucial for modern applications, enabling complex system functionality and improving efficiency through cooperation.