Skip to main content

Command Palette

Search for a command to run...

Inter-process communication

Published
2 min read
Inter-process communication
M

Hi, How are you !! Hope you doing good....

I got introduced to Cloud initially. As I went ahead learning what is cloud and how it works, then got to know a field which is DevOps that makes Cloud model more effective.

So, as I started working & got good experience on AWS. I have been learning the DevOps tool and technologies on how to use it with the Cloud, which will give me good understanding on how Cloud and DevOps go hand in hand to deploy my applications.

Last Blog Review

In the last blog we understood, what is a trap command. Why we use the trap command. The syntax of the trap command. And the real-world example of the trap command.

Today’s Agenda → Learning why Inter-process communication is important.

What is inter-process communication ?

  1. We understood what is process i.e. a running program with its own memory space, own execution state. So, this process are isolated from each other.

  2. Inter-process communication is a set of kernel-provided mechanisms that allow process to exchange data, signal events, sync execution.

  3. In short, Inter-process communication is a controlled data exchange between independent processes via. the operating system.

Why inter-process communication is required ?

  1. We know that for processes, direct memory sharing is not allowed due to following reasons:

    A. To prevent security breach

    B. Crash propagation

    C. Undefined behavior

  2. The core problem IPC solves - IPC provides controlled sharing :

    A. Kerner-approved

    B. Permission checked

    C. Synchronization aware

IPC real world examples

  1. Shell Pipeline

     ps aux | grep root
    

    What happens internally:

    1. Shell forks two processes

    2. Kernel creates a pipe

    3. ps writes output to pipe

    4. grep reads input from pipe

Without IPC:

  • grep cannot access ps output

  • Pipeline concept fails entirely

📌 IPC enables producer–consumer models

  1. IPC is required for client-server architecture

    Database Server (PostgreSQL)

    Architecture:

    • One server process

    • Many client processes

Clients need to:

  • Send SQL queries

  • Receive results

They use:

  • UNIX domain sockets

  • Or TCP sockets

Without IPC:

  • Each client would need its own DB engine

  • No centralized data consistency

  • Massive resource duplication

➡️ IPC enables service-oriented design

Multiple ways to do IPC -

  1. Named pipes : These allow processes to read from and write into it.

  2. Shared memory : This is created by one process and is further available for read from and write to this memory by multiple processes.

  3. Message queue : This is a structured and an ordered list of memory segments where processes store or retrieve data in queue fashion.

  4. Semaphores : This provides a synchronizing mechanism for processes that are accessing the same resource. It has counters that are used to control the access to shared resources by multiple processes.

Conclusion →

In this blog we understood, what is inter-process communication, why inter-process communication. Some real-time examples of it.

💡
That’s a wrap for today’s post. I hope this has provided you some valuable insights. Be sure to explore more articles on our blog for further advices. See you in next post.