mirror of https://github.com/mkerrisk/man-pages
386 lines
7.4 KiB
Groff
386 lines
7.4 KiB
Groff
.\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
|
|
.\"
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
.\" preserved on all copies.
|
|
.\"
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
.\" permission notice identical to this one.
|
|
.\"
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
.\" have taken the same level of care in the production of this manual,
|
|
.\" which is licensed free of charge, as they might when working
|
|
.\" professionally.
|
|
.\"
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
.\"
|
|
.\" FIXME There is now duplication of some of the information
|
|
.\" below in semctl.2, msgctl.2, and shmctl.2 -- MTK, Nov 04
|
|
.TH SVIPC 7 1993-11-01 "Linux 0.99.13" "Linux Programmer's Manual"
|
|
.SH NAME
|
|
svipc \- System V interprocess communication mechanisms
|
|
.SH SYNOPSIS
|
|
.nf
|
|
.B
|
|
# include <sys/types.h>
|
|
.B
|
|
# include <sys/ipc.h>
|
|
.B
|
|
# include <sys/msg.h>
|
|
.B
|
|
# include <sys/sem.h>
|
|
.B
|
|
# include <sys/shm.h>
|
|
.SH DESCRIPTION
|
|
This manual page refers to the Linux implementation of the System V
|
|
interprocess communication mechanisms:
|
|
message queues, semaphore sets, and shared memory segments.
|
|
In the following, the word
|
|
.B resource
|
|
means an instantiation of one among such mechanisms.
|
|
.SS Resource Access Permissions
|
|
For each resource, the system uses a common structure of type
|
|
.IR "struct ipc_perm"
|
|
to store information needed in determining permissions to perform an
|
|
ipc operation.
|
|
The
|
|
.B ipc_perm
|
|
structure, defined by the
|
|
.I <sys/ipc.h>
|
|
system header file, includes the following members:
|
|
.sp
|
|
.B
|
|
ushort cuid;
|
|
/* creator user ID */
|
|
.br
|
|
.B
|
|
ushort cgid;
|
|
/* creator group ID */
|
|
.br
|
|
.B
|
|
ushort uid;
|
|
/* owner user ID */
|
|
.br
|
|
.B
|
|
ushort gid;
|
|
/* owner group ID */
|
|
.br
|
|
.B
|
|
ushort mode;
|
|
/* r/w permissions */
|
|
.PP
|
|
The
|
|
.B mode
|
|
member of the
|
|
.B ipc_perm
|
|
structure defines, with its lower 9 bits, the access permissions to the
|
|
resource for a process executing an ipc system call.
|
|
The permissions are interpreted as follows:
|
|
.sp
|
|
.nf
|
|
0400 Read by user.
|
|
0200 Write by user.
|
|
.sp .5
|
|
0040 Read by group.
|
|
0020 Write by group.
|
|
.sp .5
|
|
0004 Read by others.
|
|
0002 Write by others.
|
|
.fi
|
|
.PP
|
|
Bits 0100, 0010, and 0001 (the execute bits) are unused by the system.
|
|
Furthermore,
|
|
"write"
|
|
effectively means
|
|
"alter"
|
|
for a semaphore set.
|
|
.PP
|
|
The same system header file also defines the following symbolic
|
|
constants:
|
|
.TP 14
|
|
.B IPC_CREAT
|
|
Create entry if key doesn't exist.
|
|
.TP
|
|
.B IPC_EXCL
|
|
Fail if key exists.
|
|
.TP
|
|
.B IPC_NOWAIT
|
|
Error if request must wait.
|
|
.TP
|
|
.B IPC_PRIVATE
|
|
Private key.
|
|
.TP
|
|
.B IPC_RMID
|
|
Remove resource.
|
|
.TP
|
|
.B IPC_SET
|
|
Set resource options.
|
|
.TP
|
|
.B IPC_STAT
|
|
Get resource options.
|
|
.PP
|
|
Note that
|
|
.B IPC_PRIVATE
|
|
is a
|
|
.B key_t
|
|
type, while all the other symbolic constants are flag fields and can
|
|
be OR'ed into an
|
|
.I int
|
|
type variable.
|
|
.SS Message Queues
|
|
A message queue is uniquely identified by a positive integer
|
|
.RI "(its " msqid )
|
|
and has an associated data structure of type
|
|
.IR "struct msqid_ds" ,
|
|
defined in
|
|
.IR <sys/msg.h> ,
|
|
containing the following members:
|
|
.sp
|
|
.B
|
|
struct ipc_perm msg_perm;
|
|
.br
|
|
.B
|
|
ushort msg_qnum;
|
|
/* no of messages on queue */
|
|
.br
|
|
.B
|
|
ushort msg_qbytes;
|
|
/* bytes max on a queue */
|
|
.br
|
|
.B
|
|
ushort msg_lspid;
|
|
/* PID of last msgsnd() call */
|
|
.br
|
|
.B
|
|
ushort msg_lrpid;
|
|
/* PID of last msgrcv() call */
|
|
.br
|
|
.B
|
|
time_t msg_stime;
|
|
/* last msgsnd() time */
|
|
.br
|
|
.B
|
|
time_t msg_rtime;
|
|
/* last msgrcv() time */
|
|
.br
|
|
.B
|
|
time_t msg_ctime;
|
|
/* last change time */
|
|
.TP 11
|
|
.B msg_perm
|
|
.B ipc_perm
|
|
structure that specifies the access permissions on the message
|
|
queue.
|
|
.TP
|
|
.B msg_qnum
|
|
Number of messages currently on the message queue.
|
|
.TP
|
|
.B msg_qbytes
|
|
Maximum number of bytes of message text allowed on the message
|
|
queue.
|
|
.TP
|
|
.B msg_lspid
|
|
ID of the process that performed the last
|
|
.BR msgsnd ()
|
|
system call.
|
|
.TP
|
|
.B msg_lrpid
|
|
ID of the process that performed the last
|
|
.BR msgrcv ()
|
|
system call.
|
|
.TP
|
|
.B msg_stime
|
|
Time of the last
|
|
.BR msgsnd ()
|
|
system call.
|
|
.TP
|
|
.B msg_rtime
|
|
Time of the last
|
|
.BR msgcv ()
|
|
system call.
|
|
.TP
|
|
.B msg_ctime
|
|
Time of the last
|
|
system call that changed a member of the
|
|
.B msqid_ds
|
|
structure.
|
|
.SS Semaphore Sets
|
|
A semaphore set is uniquely identified by a positive integer
|
|
.RI "(its " semid )
|
|
and has an associated data structure of type
|
|
.IR "struct semid_ds" ,
|
|
defined in
|
|
.IR <sys/sem.h> ,
|
|
containing the following members:
|
|
.sp
|
|
.B
|
|
struct ipc_perm sem_perm;
|
|
.br
|
|
.B
|
|
time_t sem_otime;
|
|
/* last operation time */
|
|
.br
|
|
.B
|
|
time_t sem_ctime;
|
|
/* last change time */
|
|
.br
|
|
.B
|
|
ushort sem_nsems;
|
|
/* count of sems in set */
|
|
.TP 11
|
|
.B sem_perm
|
|
.B ipc_perm
|
|
structure that specifies the access permissions on the semaphore
|
|
set.
|
|
.TP
|
|
.B sem_otime
|
|
Time of last
|
|
.BR semop ()
|
|
system call.
|
|
.TP
|
|
.B sem_ctime
|
|
Time of last
|
|
.BR semctl ()
|
|
system call that changed a member of the above structure or of one
|
|
semaphore belonging to the set.
|
|
.TP
|
|
.B sem_nsems
|
|
Number of semaphores in the set.
|
|
Each semaphore of the set is referenced by a non-negative integer
|
|
ranging from
|
|
.B 0
|
|
to
|
|
.BR sem_nsems\-1 .
|
|
.PP
|
|
A semaphore is a data structure of type
|
|
.I "struct sem"
|
|
containing the following members:
|
|
.sp
|
|
.B
|
|
ushort semval;
|
|
/* semaphore value */
|
|
.br
|
|
.B
|
|
short sempid;
|
|
/* PID for last operation */
|
|
.br
|
|
.B
|
|
ushort semncnt;
|
|
/* nr awaiting semval to increase */
|
|
.br
|
|
.B
|
|
ushort semzcnt;
|
|
/* nr awaiting semval = 0 */
|
|
.TP 11
|
|
.B semval
|
|
Semaphore value: a non-negative integer.
|
|
.TP
|
|
.B sempid
|
|
ID of the last process that performed a semaphore operation
|
|
on this semaphore.
|
|
.TP
|
|
.B semncnt
|
|
Number of processes suspended awaiting for
|
|
.B semval
|
|
to increase.
|
|
.TP
|
|
.B semznt
|
|
Number of processes suspended awaiting for
|
|
.B semval
|
|
to become zero.
|
|
.SS Shared Memory Segments
|
|
A shared memory segment is uniquely identified by a positive integer
|
|
.RI "(its " shmid )
|
|
and has an associated data structure of type
|
|
.IR "struct shmid_ds" ,
|
|
defined in
|
|
.IR <sys/shm.h> ,
|
|
containing the following members:
|
|
.sp
|
|
.B
|
|
struct ipc_perm shm_perm;
|
|
.br
|
|
.B
|
|
int shm_segsz;
|
|
/* size of segment */
|
|
.br
|
|
.B
|
|
ushort shm_cpid;
|
|
/* PID of creator */
|
|
.br
|
|
.B
|
|
ushort shm_lpid;
|
|
/* PID, last operation */
|
|
.br
|
|
.B
|
|
short shm_nattch;
|
|
/* no. of current attaches */
|
|
.br
|
|
.B
|
|
time_t shm_atime;
|
|
/* time of last attach */
|
|
.br
|
|
.B
|
|
time_t shm_dtime;
|
|
/* time of last detach */
|
|
.br
|
|
.B
|
|
time_t shm_ctime;
|
|
/* time of last change */
|
|
.TP 11
|
|
.B shm_perm
|
|
.B ipc_perm
|
|
structure that specifies the access permissions on the shared memory
|
|
segment.
|
|
.TP
|
|
.B shm_segsz
|
|
Size in bytes of the shared memory segment.
|
|
.TP
|
|
.B shm_cpid
|
|
ID of the process that created the shared memory segment.
|
|
.TP
|
|
.B shm_lpid
|
|
ID of the last process that executed a
|
|
.BR shmat ()
|
|
or
|
|
.BR shmdt ()
|
|
system call.
|
|
.TP
|
|
.B shm_nattch
|
|
Number of current alive attaches for this shared memory segment.
|
|
.TP
|
|
.B shm_atime
|
|
Time of the last
|
|
.BR shmat ()
|
|
system call.
|
|
.TP
|
|
.B shm_dtime
|
|
Time of the last
|
|
.BR shmdt ()
|
|
system call.
|
|
.TP
|
|
.B shm_ctime
|
|
Time of the last
|
|
.BR shmctl ()
|
|
system call that changed
|
|
.BR shmid_ds .
|
|
.SH "SEE ALSO"
|
|
.BR msgctl (2),
|
|
.BR msgget (2),
|
|
.BR msgrcv (2),
|
|
.BR msgsnd (2),
|
|
.BR semctl (2),
|
|
.BR semget (2),
|
|
.BR semop (2),
|
|
.BR shmat (2),
|
|
.BR shmctl (2),
|
|
.BR shmdt (2),
|
|
.BR shmget (2),
|
|
.BR ftok (3)
|