System Synchronization (IPC)

Interprocess Communication (IPC)

Processes within a system may be Independent or Cooperating.

Cooperating process can affect or be affected by other processes, including sharing data

Cooperating processes need interprocess communication (IPC)

Two models of IPC:

  1. Shared memory
  2. Message passing

Shared Memory

Shared Memory is the memory that may be simultaneously (同时) accessed by multiple programs with an intent to provide communication among them or avoid redundant copies.

Two or more process can access the common memory.
Shared Memory

Synchronous and Asynchronous Message Passing:

Blocking is considered synchronous
◦ Blocking send has the sender block until the message is received
◦ Blocking receive has the receiver block until a message is available

Non-blocking is considered asynchronous
◦ Non-blocking send has the sender send the message and continue
◦ Non-blocking receive has the receiver receive a valid message or null

There are basically three most preferred combinations:

  1. Blocking send and blocking receive
  2. Non-blocking send and Non-blocking receive
  3. Non-blocking send and Blocking receive (Mostly used)

Direct message passing

Definition: The process which want to communicate must explicitly name the recipient or sender of communication.

The communication link get established automatically, which can be either unidirectional or bidirectional

But one link can be used between one pair of the sender and receiver and one pair of sender and receiver should not possess more than one pair of link.

Disadvantage: If the name of one process changes, this method will not work.

Indirect message passing

Definition: Processes uses mailboxes (also referred to as ports) for sending and receiving messages.

A single link can be associated with many processes.

Each pair of processes can share several communication links and these link may be unidirectional or bi-directional.

The required operations are:

  1. create a mail box,
  2. use this mail box for sending and receiving messages,
  3. destroy the mail box.

Disadvantage: More than two processes sharing the same mailbox and one of the process sends a message to the mailbox, which process will be the receiver?
Solution:

  1. forcing that only two processes can share a single mailbox
  2. enforcing that only one process is allowed to execute the receive at a given time
  3. select any process randomly and notify the sender about the receiver.

How are links established?

Direct communication: name process to communicate

Indirect communication: name mailbox (port) to communicate, which consists of queue of messages. Sender keeps the message in mailbox and receiver picks them up.

Implementation of communication link:
physical (e.g., shared memory, hardware bus)
logical (e.g., logical properties)

Can a link be associated with more than two processes?

In Direct message passing, a link can be only used between one pair of the sender and receiver. (NO)
In Indirect message passing, a link can be associated with many processes.(YES)

How many links can there be between every pair of communicating processes?

In Direct message passing, one pair of sender and receiver can only have one pair of link.
In Indirect message passing, one pair of processes can share several communication links.

What is the capacity of a link? Is the size of a message that the link can accommodate fixed or variable?

A link has some capacity that determines the number of messages that can reside in it.

  1. zero capacity
    In zero capacity, sender wait until receiver inform sender that it has received the message.

  2. bounded capacity

  3. unbounded capacity
    In non-zero capacity cases, a process does not know whether a message has been received or not after the send operation.

The message size can be of fixed size or of variable size.
Fixed size is easy for OS designer but complicated for programmer
Variable size is easy for programmer but complicated for the OS designer

  • A standard message can have two parts: header and body.
    The header part is used for storing Message type, destination id, source id, message length and control information.

  • Generally, message is sent using FIFO style.

Is a link unidirectional or bi-directional?

Both Direct message passing and In Indirect message passing can be either unidirectional or bidirectional.

Reference

https://www.geeksforgeeks.org/inter-process-communication-ipc/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值