Skip Navigation Links | |
Exit Print View | |
Programming Interfaces Guide Oracle Solaris 11.1 Information Library |
2. Session Description Protocol API
Permissions for Messages, Semaphores, and Shared Memory
IPC Interfaces, Key Arguments, and Creation Flags
Sending and Receiving Messages
Accessing a Shared Memory Segment
Controlling a Shared Memory Segment
Attaching and Detaching a Shared Memory Segment
8. Programming With XTI and TLI
10. Transport Selection and Name-to-Address Mapping
11. Real-time Programming and Administration
POSIX interprocess communication (IPC) is a variation of System V interprocess communication. Like System V objects, POSIX IPC objects have read and write, but not execute, permissions for the owner, the owner's group, and for others. There is no way for the owner of a POSIX IPC object to assign a different owner. POSIX IPC includes the following features:
t
Messages allow processes to send formatted data streams to arbitrary processes.
Semaphores allow processes to synchronize execution.
Shared memory allows processes to share parts of their virtual address space.
Unlike the System V IPC interfaces, the POSIX IPC interfaces are all multithread safe.
The POSIX message queue interfaces are listed in the following table.
Table 6-2 POSIX Message Queue Interfaces
|
POSIX semaphores are much lighter weight than are System V semaphores. A POSIX semaphore structure defines a single semaphore, not an array of up to 25 semaphores.
The POSIX semaphore interfaces are shown below.
Connects to, and optionally creates, a named semaphore
Initializes a semaphore structure (internal to the calling program, so not a named semaphore)
Ends the connection to an open semaphore
Ends the connection to an open semaphore and causes the semaphore to be removed when the last process closes it
Initializes a semaphore structure (internal to the calling program, so not a named semaphore)
Copies the value of the semaphore into the specified integer
Blocks while the semaphore is held by other processes or returns an error if the semaphore is held by another process
POSIX shared memory is actually a variation of mapped memory (see Creating and Using Mappings). The major differences are:
You use shm_open to open the shared memory object instead of calling open(2).
You use shm_unlink to close and delete the object instead of calling close(2) which does not remove the object.
The options in shm_open substantially fewer than the number of options provided in open(2).