CS139-lecture-20210921

Processes cont. #

Termination #

image_2021-09-21-13-47-02 image_2021-09-21-13-55-00

A parent cannot wait on a grandchild.

Inter-process communication #

image_2021-09-21-14-02-36 image_2021-09-21-14-06-52

Message passing

  • uses send and receieve 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)

image_2021-09-21-14-17-40

Shared memory communication #

image_2021-09-21-14-36-26 image_2021-09-21-14-20-17

This uses a circular buffer:

image_2021-09-21-14-21-19 image_2021-09-21-14-21-29 image_2021-09-21-14-23-30

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 #

image_2021-09-21-14-36-37 image_2021-09-21-14-37-21 image_2021-09-21-14-40-47 image_2021-09-21-14-40-52 image_2021-09-21-14-42-21

A good analogy for indirect communication is a drop off mailbox.

image_2021-09-21-14-43-45 image_2021-09-21-14-44-03