The Linux Programming Interface

(nextflipdebug5) #1

Chapter 45: Introduction to System V IPC......................................................................


System V IPC is the label used to refer to three different mechanisms for interpro-
cess communication:

z Message queues can be used to pass messages between processes. Message
queues are somewhat like pipes, but differ in two important respects. First,
message boundaries are preserved, so that readers and writers communicate in
units of messages, rather than via an undelimited byte stream. Second, each
message includes an integer type field, and it is possible to select messages by
type, rather than reading them in the order in which they were written.
z Semaphores permit multiple processes to synchronize their actions. A semaphore
is a kernel-maintained integer value that is visible to all processes that have the
necessary permissions. A process indicates to its peers that it is performing some
action by making an appropriate modification to the value of the semaphore.
z Shared memory enables multiple processes to share the same region (called a
segment) of memory (i.e., the same page frames are mapped into the virtual
memory of multiple processes). Since access to user-space memory is a fast
operation, shared memory is one of the quickest methods of IPC: once one
process has updated the shared memory, the change is immediately visible to
other processes sharing the same segment.

Although these three IPC mechanisms are quite diverse in function, there are good
reasons for discussing them together. One reason is that they were developed
Free download pdf