GNU Info

Info Node: (ipc.info)syscalls

(ipc.info)syscalls


Next: Messages Prev: perms Up: Overview
Enter node , (file) or (file)node

IPC system calls
================

   This section provides an overview of the IPC system calls. See the
specific sections on each type of resource for details.

   Each type of mechanism provides a "get", "ctl" and one or more "op"
system calls that allow the user to create or procure the resource
(get), define its behaviour or destroy it (ctl) and manipulate the
resources (op).

The "get" system calls
----------------------

   The `get' call typically takes a KEY and returns a numeric ID that
is used for further access.  The ID is an index into the resource
table. A sequence number is maintained and incremented when a resource
is destroyed so that access using an obsolete ID is likely to fail.

   The user also specifies the permissions and other behaviour
charecteristics for the current access. The flags are or-ed with the
permissions when invoking system calls as in:
     msgflg = IPC_CREAT | IPC_EXCL | 0666;
     id = msgget (key, msgflg);

   * `key' : IPC_PRIVATE => new instance of resource is initialized.

   * `flags' :
          IPC_CREAT : resource created for KEY if it does not exist.

          IPC_CREAT | IPC_EXCL : fail if resource exists for KEY.

   * returns : an identifier used for all further access to the
     resource.

   Note that IPC_PRIVATE is not a flag but a special `key' that ensures
(when the call is successful) that a new resource is created.

   Use of IPC_PRIVATE does not make the resource inaccessible to other
users. For this you must set the access permissions appropriately.

   There is currently no way for a process to ensure exclusive access
to a resource. IPC_CREAT | IPC_EXCL only ensures (on success) that a new
resource was initialized. It does not imply exclusive access.

See Also : Note: msgget, Note: semget, Note: shmget.

The "ctl" system calls
----------------------

   Provides or alters the information stored in the structure that
describes the resource indexed by ID.

     #include <sys/msg.h>
     struct msqid_ds buf;
     err = msgctl (id, IPC_STAT, &buf);
     if (err)
             !$#%*
     else
             printf ("creator uid = %d\n", buf.msg_perm.cuid);
             ....

Commands supported by all `ctl' calls:
   * IPC_STAT : read info on resource  specified by id into user
     allocated buffer. The user must have read access to the resource.

   * IPC_SET : write info from buffer into resource data structure. The
     user must be owner creator or super-user.

   * IPC_RMID : remove resource. The user must be the owner, creator or
     super-user.

   The IPC_RMID command results in immediate removal of a message queue
or semaphore array. Shared memory segments however, are only destroyed
upon the last detach after IPC_RMID is executed.

   The `semctl' call provides a number of command options that allow
the user to determine or set the values of the semaphores in an array.

See Also: Note: msgctl, Note: semctl, Note: shmctl.

The "op" system calls
---------------------

   Used to send or receive messages, read or alter semaphore values,
attach or detach shared memory segments.  The IPC_NOWAIT flag will
cause the operation to fail with error EAGAIN if the process has to
wait on the call.

`flags' : IPC_NOWAIT  => return with error if a wait is required.

See Also: Note: msgsnd,Note: msgrcv,Note: semop,Note: shmat,
Note: shmdt.


automatically generated by info2www version 1.2.2.9