936
Chapter 45
On Linux, the ipcs –l command can be used to list the
limits on each of the IPC
mechanisms. Programs can employ the Linux-specific
IPC_INFO
ctl operation to
retrieve the same information.
45.9
Summary
System V IPC is the name given to three IPC mechanisms that first appeared widely
in System V, and have subsequently been ported to most UNIX implementations
and incorporated into various standards. The three IPC mechanisms are message
queues, which allow
processes to exchange messages; semaphores, which allow pro-
cesses to synchronize access to shared resources; and shared memory, which allows
two or more processes to share the same pages of memory.
The three IPC mechanisms have many similarities in their APIs and semantics.
For
each IPC mechanism, a get system call creates or opens an object. Given an integer
key, the get calls return an integer identifier used to refer to the object in subsequent
system calls. Each IPC mechanism also has a corresponding a ctl call that is used to
delete an object and to retrieve and modify various attributes (e.g., ownership and
permissions) in an object’s associated data structure.
The algorithm used to generate identifiers for new
IPC objects is designed to
minimize the possibility of the same identifier being (immediately) reused if an
object is deleted, even if the same key is used to create a new object. This enables
client-server applications to function correctly—a restarted
server process is able to
detect and remove IPC objects created by its predecessor, and this action invali-
dates the identifiers held by any clients of the previous server process.
The ipcs command lists the System V IPC objects that currently exist on the
system. The ipcrm command is used to remove System IPC objects.
On Linux, files in the
/proc/sysvipc
directory can be used
to obtain information
about all of the System V IPC objects on the system.
Each IPC mechanism has an associated set of limits that can be used to avoid
exhaustion of system resources by preventing the creation of an arbitrary number
of IPC objects. Various files under the
/proc/sys/kernel
directory can be used to
view and modify these limits.
Chia sẻ với bạn bè của bạn: