P3L3: Inter-Process Communication Flashcards

1
Q

What does the OS need to do to enable processes to share memory?

A

The OS needs to map their virtual addresses to the same physical memory.

This involves changing each processes page table so that the each one has VPNs that point to shared PFNs.

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

When processes share memory, do they use the same virtual addresses to access the same memory?

A

There is no guarantee the virtual addresses will be the same.

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

For processes to communicate using a shared memory-based communication channel, do they still have to copy data from one location to another?

A

Data copying is reduced but not eliminated.

Only part of each address space is mapped to the shared memory, so the processes will sometimes need to copy from the local part of their address space to the shared part.

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

What are the costs associated with message-based IPCs?

A

Message-based IPCs copy data to the kernel each time they send a message, which also requires a context switch to the kernel, and then the same thing happens on the receiving end. That is two data copies and two context switches for a one-way communication.

Each message has significant overhead.

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

What are the costs associated with shared memory IPC?

A

A single, large, up-front cost of mapping the address spaces to the shared physical memory. While this single cost is large, it is amortized over the subsequent sending of messages. Especially for large data transfers, this one-time cost can be worthwhile.

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

What are the tradeoffs between message-based vs. shared-memory-based communication?

A

MESSAGE-BASED
Pros:
- Simplicity: the OS handles all channel management and synchronization operations.
Cons:
- This means the OS gets involved in each message: every send and receive requires a system call and a data copy, increasing overhead.

SHARED MEMORY
Pros:
- After mapping virtual to physical memory, the OS is out of the way. This eliminates system calls and reduces data copies.
Cons:
- Developer has to define the communication protocol and explicitly handle all synchronization.

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

What mechanisms are useful for synchronizing different processes?

A
  • Mutexes: Use them like we did in multithreading
  • Semaphores: If we initialize to 1, will act like mutex and only allow one process to access. The locking process decrements semaphore to 0, increments back to 1 on unlock.
  • Message-passing IPCs: Can be used to share info about mutexes and semaphores between processes and to let other processes know when read/write operations are complete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly