Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

Section 15.6 XSI IPC 559


Permission Bit
user-read 0400
user-write (alter) 0200
group-read 0040
group-write (alter) 0020
other-read 0004
other-write (alter) 0002

Figure 15.24XSI IPC permissions

Some implementations define symbolic constants to represent each permission, but
these constants arenot standardized by the Single UNIX Specification.

15.6.3 Configuration Limits


All three forms of XSI IPC have built-in limits that we may encounter.Most of these
limits can be changed by reconfiguring the kernel. We describe the limits when we
describe each of the three forms of IPC.

Each platform provides its own way to report and modify a particular limit. FreeBSD 8.0,
Linux 3.2.0, and Mac OS X 10.6.8 provide thesysctlcommand to view and modify kernel
configuration parameters. On Solaris 10, changes to kernel IPC limits aremade with the
prctlcommand.
On Linux, you can display the IPC-related limits by runningipcs -l.OnFreeBSD and Mac
OS X, the equivalent command isipcs -T.OnSolaris, you can discover the tunable
parameters by runningsysdef -i.

15.6.4 Advantages and Disadvantages


Afundamental problem with XSI IPC is that the IPC structures aresystemwide and do
not have a reference count. For example, if we create a message queue, place some
messages on the queue, and then terminate, the message queue and its contents arenot
deleted. Theyremain in the system until specifically read or deleted by some process
callingmsgrcvormsgctl, by someone executing theipcrm( 1 )command, or by the
system being rebooted. Comparethis with a pipe, which is completely removed when
the last process to reference it terminates.With a FIFO, although the name stays in the
file system until explicitly removed, any data left in a FIFO is removed when the last
process to reference the FIFO terminates.
Another problem with XSI IPC is that these IPC structures arenot known by names
in the file system.We can’t access them and modify their properties with the functions
we described in Chapters 3 and 4. Almost a dozen new system calls (msgget,semop,
shmat,and so on) wereadded to the kernel to support these IPC objects.We can’t see
the IPC objects with anlscommand, we can’t remove them with thermcommand, and
we can’t change their permissions with thechmod command. Instead, two new
commands —ipcs( 1 )andipcrm( 1 )—wereadded.
Free download pdf