P3L3. Inter-Process Communication Flashcards

1
Q

What is inter-process communication (IPC)? What are some examples?

A

OS supported mechanisms for interaction among processes (coordination and communication)

  • message passing IPC
    • sockets, pipes, message queues
  • memory-based IPC
    • shared memory, memory mapped files
  • higher-level semantics
    • files, RPC
  • synchronization
    • primatives
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does message passing IPC work?

What is the kernel responsible for and how much user/kernel boudary crossings does this IPC require?

A

send/recv messages

OS creates and maintains a channel (e.g., buffer, FIFO queue)

OS provides interface to process - a port

  • process send/write messages to a port
  • process recv/read messages from a port

kernel required to:

  • establish communication
  • perform each IPC operation
    • send: system call + data copy
    • recv: system call + data copy

Request/Response:

4x user/kernel crossings + 4x data copies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the pros/cons of message passing IPC?

A

Pros:

+ simplicity. kernel does channel management and sychnronization

Cons:

  • overhead. requires crossing user/kernel boundary for each message
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do pipes work? What form of IPC?

A

Carry byte stream between two processes (e.g., connect output from one process to input of another)

Pipes are an example of message passing IPC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do message queues work?

What is the OS responsible for?

What form of IPC?

A

Carry “messages” among processes

OS managment includes priorities, scheduling of message delivery

APIS: SysV and POSIX

Message queues are an example of message passing IPC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do sockets work?

What form of IPC?

A
  • the sockets API supports send() and recv() operations that allow processes to send message buffers in and out of the kernel communication buffer.
  • socket() creates a kernel-level socket buffer
  • associate necessary kernel-level processing (TCP/IP)

> if different machines, channel is between processes and network device

> if same machone, bypass full protocol stack

Sockets are an example of message passing IPC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does shared memory IPC work?

What is the OS responsible for and how much user/kernel boudary crossings does this IPC require?

A

processes read and write to a shared memory region

OS establishes shared channel between the processes:

  1. physical pages mapped into virtual address space
  2. VA(P1) and VA(P2) map to the same physcial address
  3. VA(P1) != VA(P2)
  4. physical memory doesn’t need to be contiguous
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the pros/cons of shared memory IPC?

A

Pros:

+ one shared memory segment is established the OS is out of the way

+ system calls only for setup

+ data calls potentially reduced (but not eliminated) for data to be visible to both processes it but be allocated from virtual memory addresses that belong to the shared region. if that’s not the case then data from the same address space has to be copied in and out of the shared memory region

Cons:

  • explicit sychronization
  • communication protocol, shared buffer management is the programmer’s responsibility

APIS: SysV, POSIX, memory mapped files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Copy (messages) vs Map (shared memory)

A

Copy

  • CPU cycles to copy data to/from port

Map

  • CPU cycles to map memory into address space
  • CPU to copy data to channel

=> set up once, use many times = good payoff

=> can perform well for 1-time use (e.g., large data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly