The Linux Programming Interface: a linux and unix system Programming Handbook



tải về 6.93 Mb.
Chế độ xem pdf
trang790/806
Chuyển đổi dữ liệu08.07.2022
Kích6.93 Mb.
#52607
1   ...   786   787   788   789   790   791   792   793   ...   806
The Linux Programming Interface

45.8
IPC Limits
Since System V IPC objects consume system resources, the kernel places various
limits on each class of IPC object in order to prevent resources from being
exhausted. The methods for placing limits on System V IPC objects are not speci-
fied by SUSv3, but most UNIX implementations (including Linux) follow a similar
framework for the types of limits that may be placed. As we cover each System V
IPC mechanism in the following chapters, we discuss the associated limits and note
differences from other UNIX implementations.
Although the types of limits that can be placed on each class of IPC object are
generally similar across various UNIX implementations, the methods of viewing
and changing these limits are not. The methods described in the following chapters
are Linux-specific (they generally involve the use of files in the 
/proc/sys/kernel
directory); things are done differently on other implementations.


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.

tải về 6.93 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   786   787   788   789   790   791   792   793   ...   806




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương