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



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

Further information
Information about the implementation of System V IPC on Linux can be found in
[Maxwell, 1999] and [Bovet & Cesati, 2005]. [Goodheart & Cox, 1994] describes
the implementation of System V IPC for System V Release 4.
45.10 Exercises
45-1.
Write a program to verify that the algorithm employed by ftok() uses the file’s i-node
number, minor device number, and proj value, as described in Section 45.2. (It is
sufficient to print all of these values, as well as the return value from ftok(), in
hexadecimal, and inspect the results for a few examples.)
45-2.
Implement ftok().
45-3.
Verify (by experiment) the statements made in Section 45.5 about the algorithm
used to generate System V IPC identifiers.


S Y S T E M V M E S S A G E Q U E U E S
This chapter describes System V message queues. Message queues allow processes
to exchange data in the form of messages. Although message queues are similar to
pipes and FIFOs in some respects, they also differ in important ways:
z
The handle used to refer to a message queue is the identifier returned by a call
to msgget(). These identifiers are not the same as the file descriptors used for
most other forms of I/O on UNIX systems.
z
Communication via message queues is message-oriented; that is, the reader
receives whole messages, as written by the writer. It is not possible to read part
of a message, leaving the remainder in the queue, or to read multiple messages
at a time. This contrasts with pipes, which provide an undifferentiated stream
of bytes (i.e., with pipes, the reader can read an arbitrary number of bytes at a
time, irrespective of the size of data blocks written by the writer).
z
In addition to containing data, each message has an integer type. Messages can
be retrieved from a queue in first-in, first-out order or retrieved by type.
At the end of this chapter (Section 46.9), we summarize a number of limitations of
System V message queues. These limitations lead us to the conclusion that, where
possible, new applications should avoid the use of System V message queues in
favor of other IPC mechanisms such as FIFOs, POSIX message queues, and sockets.
However, when message queues were initially devised, these alternative mecha-
nisms were unavailable or were not widespread across UNIX implementations.


938
Chapter 46
Consequently, there are various existing applications that employ message queues,
and this fact forms one of the primary motivations for describing them.

tải về 6.93 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   787   788   789   790   791   792   793   794   ...   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