Processes cont. #
Termination #
A parent cannot wait on a grandchild.
Inter-process communication #
Message passing
- uses
send
andreceieve
API calls - slower, more expensive
- small amount of data distributed
Shared memory
- process A sets aside some memory for process B
- restrictions must be lifted by kernel
- faster and cheaper because minimal kernel involvement
- doesn’t work for distributed systems (2 processes on remote machines)
Shared memory communication #
This uses a circular buffer:
We can only hold BUFFER_SIZE - 1
items, because we don’t want in
and out
to point at the same item when the buffer is full.
in == out
indicates that the buffer is empty.
If we add BUFFER_SIZE
items, then in == out
and it’ll get stuck in the consumer’s while loop.
If we introduce a counter, we can utilize the entire buffer.
Message passing memory communication #
A good analogy for indirect communication is a drop off mailbox.