/ COMPUTER-FUNDAMENTAL

Inter-Process Communication

IPC


Process has 2 options: Independent Process and Cooperating Process.
Independent Process does not share data.
Cooperating Process shares data.
IPC is an action that shares data between Process.


Advantages of Cooperate Process

  • Information sharing
    When people can share one file together.
  • Computation speedup
    Processes work together in one file, finish fast.
  • Modularity
    Process and thread can divide the system features more effectively.
  • Convenience
    People can play multi-process at the same time

Messaging passing VS Shared memory

IPC has 2 methods: messaging passing and shared memory.

  • Message passing
    Kernel (OS) is an agent that deliver data between Process for memory protection.
    It is safe and doesn’t have synchronization issue because OS synchronizes memory.
    However, the performance is worse.
  • Shared memory
    Processes create shared memory and use it.
    The performance is good, but it has synchronization issue.
    Application synchronizes the memory.

IPC Imagine that Process A has Rss1 and Process B has Rss2.
When they try to share the resources, Memory protection blocks process A approaching process B directly. If Process A can approach Process B directly, Process A can kill Process B.


Messaging Passing

To share the Resources, OS needs to help.
Process A passes a message to Kernel, Kernel passes the message to B.

messagin passing

  • Direct communication
    Kernel passes messages directly
  • Indirect communication
    Kernel is like Lost property office. When A puts a message in Kernel,
    B come and get the message.

    Messaging passing is not efficiency and raise overhead.
    (a) picture domonstrates Indirect message, the above picture is Direct message.

Shared Memory

Shared memory is better performance than Messaging Passing.
However, It has synchronization issue.


When A writes a message in shared memory, B does not know when the message is written.
So, it should synchronize the time, which is known as synchronization issue.


IPC represents every communication between Processes.
Process 1 in Computer A can communicate with Process 2 in Computer B by using IPC.
So, the networking is also called IPC.
IPC is called Socket, RPC (Remote Procedure Call) in C++, RMI in Java.