Inter-Process Communications (IPC)


Shared Memory

(Usually RAM; could be files or other forms of "memory")

from Wikipedia

Issues

Solutions

New Issue

Examples

Example #1
    Producer: overwrite memory, starting from the “top”, with numbers given to
              you in sorted order.
        412  18  17  411  414  413  415   50  54
    Consumer: Return the median value (ideally 411)
==> Problem: Consumer consumes before producer is done producing! (Race condition)
Example #2
    for ( int i = 1000; i < 1012; i++ )
        memory[i] = nn
==> Problem: Processes are overwriting each other; need synchronization, “atomic” operations
Example #3
    A:  ... b = x + (5 * x); ...
    B:  ... x = z + (3 * z); ...
(variation of example from Wikipedia article on critical sections)
==> Problem: A might get two different values of x!
Deadlock Example
    Get resource A
    Get resource B
        Do something with them
        Put result in resource C
    Release resources
    Get resource B
    Get resource A
        Do something with them
        Put result in resource D
    Release resources
==> Example: 4 cars arrive at 4-way Stop Sign at the same time

Alyce Brady, Kalamazoo College