IPC: We have discussed a number of IPC mechanisms in
class. In this assignment, you are to compare important properties of
these mechanisms. Investigate the following:
- Can the sender/producer process terminate and the consumer "pick up"
the data if it starts after the producer process has terminated?
- How can an external observer detect whether and how much data there
is waiting to be read, without interfering with the data? (An external
observer is another process on the same machine, e.g., a user running a
shell. It is allowable to pass a file name or other identifying
information to the external observer.) Note that this is not possible
with some IPC mechanisms.
- What is the data transfer speed between two processes, when
transferring large messages (4 kB, say)?
- Is there flow control and if so, how much data can the sender send
before it blocks, if the receiver is not reading from the IPC mechanism?
(This question does not apply to shared memory, obviously.)
Compare the following mechanisms:
- Unix sockets, both datagram and stream;
- network sockets on the same host, both datagram and stream;
- message queues;
mkfifo()
;
pipe()
;
socketpair()
;
- SysV shared memory.
You can either write one program that forks a client and a server or
write separate client and server programs that test the properties above
and measure the speed. (pipe
and socketpair
obviously will have to be done as a single program to pass around file
descriptors.)
The communication mechanism should be selectable by the -c
flag, with the names unix, network, msg,
shm, mkfifo.