IPC: Shared Memory
When two or more processes communicate via shared memory, each of these processes can read from and write to the same, shared chunk of main memory. [Some part of each process's address space, though, isn't shared with other processes.]
- Usually, the shared memory chunk initially belongs to one of the processes. To establish memory-sharing, other processes issue system calls to receive access permissions to this chunk of memory.
- Once the permission is received, this memory chunk becomes a part of the issuer's address space as well.
- Shared Memory is faster once it is set up, because no system calls are required once the communication was established, and memory access occurs at normal memory speeds.
- Therefore, shared memory is generally preferable when large amounts of information must be shared quickly on the same computer.
- A classical example of this IPC method is the Producer-Consumer scenario, shown on Topic 9's slide 4.