Introduction to Processes and IPC

Learn why operating systems provide Interprocess Communication (IPC) mechanisms to enable controlled, secure data exchange between independent programs.

So far in this course, we have worked with a single program at a time. Even when we introduced parallel programming, multiple threads executed within the same process and shared the same memory space.

Processes are different. A process is an independent instance of a running program. Each process has its own protected memory space, its own variables, stack, and resources. The operating system enforces this separation to ensure stability and security.

Because of this isolation, processes cannot directly access each other’s variables. If two separate programs are running, they cannot simply share a global variable the way threads can. This raises an important question: How do processes exchange information? The answer lies in Interprocess Communication (IPC).

What is a process?

A process is a program in execution. When you run a compiled C program, the operating system loads the program into memory, allocates memory regions (stack, heap, data segment), assigns a unique process identifier (PID), and schedules it for execution.

Each process runs independently. Even if two programs are running the same executable file, they are separate processes with separate memory spaces. For example, if you open two terminal windows and run the same program in both, they do not share variables. Changing a variable in one does not affect the other.

This memory isolation is intentional. It prevents one program from accidentally corrupting another program’s data.

Why can processes not share variables

When threads run inside a single process, they share the same address space. That is why synchronization mechanisms like mutexes are necessary. Processes, however, do not share address spaces by default. A pointer in one process has no meaning in another process. Even if two processes define a variable with the same name, those variables exist in completely different memory regions. This design provides:

  • Safety: One process cannot overwrite another’s memory.

  • Stability: A crash in one process does not directly corrupt others.

  • Security: Unauthorized memory access is prevented.

But it also means processes must use controlled mechanisms to communicate.

What is Interprocess Communication (IPC)?

Interprocess Communication refers to the mechanisms provided by the operating system that allow separate processes to exchange data. Unlike threads, which share memory directly, processes must communicate through:

  • Kernel-managed data channels.

  • Shared memory regions explicitly created for sharing.

  • Structured message-passing systems.

  • Signals for simple notifications.

The operating system acts as an intermediary. Whenever two processes communicate, the kernel ensures that the data transfer is controlled and secure.

It is important to clearly distinguish IPC from threading. Threads share the same memory space, communicate through shared variables, and require synchronization to prevent race conditions. In contrast, processes have separate memory spaces, cannot directly access each other’s variables, and communicate through operating-system mechanisms. They are independent execution environments managed by the operating system. IPC is therefore necessary only when communication occurs between separate processes.

Why IPC is essential

Modern systems are rarely built as a single monolithic program. Instead, they are composed of multiple cooperating processes. For example, a web server process communicating with a database process, a shell creating child processes and connecting them with pipelines, a graphical application interacting with background services, or system utilities exchanging data.

Without IPC, large systems would be tightly coupled and fragile. IPC enables:

  • Modularity: Programs can be separated into components.

  • Scalability: Different components can run independently.

  • Fault isolation: Failure in one process does not destroy others.

  • Security: Controlled boundaries between components.

Operating systems provide several mechanisms for interprocess communication. In this module, we will explore:

  1. Pipes and FIFOs

  2. Shared memory

  3. Message queues

  4. Signals

Each mechanism solves a different coordination problem and has different performance characteristics. Some are simple and sequential; others are fast but require careful synchronization. Understanding their trade-offs is essential for system-level programming.

A simple example: Process creation

Before studying IPC mechanisms, it is useful to understand that processes can create other processes. The fork() system call creates a new child process that is a copy of the parent process.

Let's see an example below: