svipcのヘルプ・マニュアル
日本語 英語
svipc --help
man svipc
SVIPC(7) Linux Programmer’s Manual SVIPC(7)
名前
svipc - System V プロセス間通信機構
書式
#include
#include
#include
#include
#include
説明
このマニュアル・ページは System V プロセス間通信 (interprocess communi-
cation; IPC) 機構の Linux における実装を説明する。このプロセス間通信 機
構 に は、メッセージ・キュー (message queue)、セマフォー集合 (semaphore
set)、共有メモリ・セグメント (shared memory segment) などがある。以下で
資 源 (resource) という用語を使用した場合にはこれらの機構のどれかを意味
する。
資源へのアクセス許可
システムのそれぞれの資源は、IPC への操作を許可するかどうかを決定する た
めの情報を共通の構造体 struct ipc_perm に格納して使用する。 ipc_perm 構
造体は、ヘッダーファイルの に定義されており、以下のメンバー
が含まれている:
struct ipc_perm {
uid_t cuid; /* 作成者のユーザーID */
gid_t cgid; /* 作成者のグループID */
uid_t uid; /* 所有者のユーザーID */
gid_t gid; /* 所有者のグループID */
unsigned short mode; /* 読み書きの許可 */
};
ipc_perm 構造体の mode メンバーは以下の 9 ビットで、プロセスの IPC シス
テム・コールによる資源へのアクセス許可を定義する。許可は以下のように 解
釈される:
0400 ユーザーによる読み込み。
0200 ユーザーによる書き込み。
0040 グループによる読み込み。
0020 グループによる書き込み。
0004 他人による読み込み。
0002 他人による書き込み。
システムはビット 0100, 0010, 0001 (実行ビット) は使用しない。さらに、セ
マフォーの場合には "書き込み(write)" は実際には "変更(alter)" を意味 す
る。
同じヘッダーファイルには以下のシンボルの定義が含まれている:
IPC_CREAT キー(key)が存在しない場合には新たなエントリを作成する。
IPC_EXCL キー(key)が存在する場合には失敗する。
IPC_NOWAIT 要求が待たされる場合にはエラーになる。
IPC_PRIVATE プライベート・キー。
IPC_RMID 資源を削除する。
IPC_SET 資源にオプションを設定する。
IPC_STAT 資源のオプションを取得する。
IPC_PRIVATE は key_t 型である。その他の全てのシンボルはフラグ・フィール
ドとして int 変数に OR 演算で格納することができる。
メッセージ・キュー
メッセージ・キューは正の整数 (msqid) によって識別され、 に
定義されている構造体 struct msqid_ds に結びつけられている。この構造体は
以下のメンバーを含んでいる:
struct msqid_ds {
struct ipc_perm msg_perm;
msgqnum_t msg_qnum; /* キューにあるメッセージの数 */
msglen_t msg_qbytes; /* キューの最大バイト数 */
pid_t msg_lspid; /* 最後に msgsnd(2) をした PID */
pid_t msg_lrpid; /* 最後に msgrcv(2) をした PID */
time_t msg_stime; /* 最後に msgsnd(2) をした時間 */
time_t msg_rtime; /* 最後に msgrcv(2) をした時間 */
time_t msg_ctime; /* 最後に変更された時間 */
};
msg_perm メッセージ・キューへのアクセス許可を指定する ipc_perm 構造体
。
msg_qnum 現在、このメッセージ・キューにあるメッセージの数。
msg_qbytes メッセージ・キューに入れることができるメッセージの最大バイト
数。
msg_lspid 最後に msgsnd(2) システム・コールを行なったプロセスの ID。
msg_lrpid 最後に msgrcv(2) システム・コールを行なったプロセスの ID。
msg_stime 最後に msgsnd(2) システム・コールを行なった時間。 msg_rtime
最後に msgrcv(2) を行なった時間。
msg_ctime 最後に msqid_ds 構造体のメンバーが変更された時間。
セマフォー集合
セ マフォー集合は正の整数 (semid) によって識別され、 に定義
されている構造体 struct semid_ds に結びつけられている。この構造体は以下
のメンバーを含んでいる:
struct semid_ds {
struct ipc_perm sem_perm;
time_t sem_otime; /* 最後に操作した時間 */
time_t sem_ctime; /* 最後に変更した時間 */
unsigned long sem_nsems; /* 集合の中にあるセマフォー数 */
};
sem_perm セマフォー集合へのアクセス許可を指定する ipc_perm 構造体。
sem_otime 最後に semop(2) システム・コールを行なった時間。
sem_ctime 最後に semctl(2) を行なって上記の構造体のメンバーを変更する
か、セマフォー集合に属するセマフォーを変更した時間。
sem_nsems セマフォー集合の中にあるセマフォーの数。集合の中にあるそれぞ
れ の セ マ フ ォ ー は負でない整数によって参照され、 0 から
sem_nsems-1 までの番号を持つ。
セマフォーは struct sem 型のデータ構造体であり、以下のメンバーを含ん で
いる:
struct sem {
int semval; /* セマフォーの値 */
int sempid; /* 最後に操作したプロセス ID */
};
semval セマフォー値: 負でない整数。
sempid このセマフォーを最後に操作したプロセスの ID。
共有メモリ・セグメント
共 有 メモリ・セグメトは正の整数 (shmid) によって識別され、
に定義されている struct shmid_ds 構造体に結びつけられている。この構造体
は以下のメンバーを含んでいる:
struct shmid_ds {
struct ipc_perm shm_perm;
size_t shm_segsz; /* セグメントのサイズ */
pid_t shm_cpid; /* 作成者のプロセス ID */
pid_t shm_lpid; /* 最後に操作したプロセス ID */
shmatt_t shm_nattch; /* 現在、付加している数 */
time_t shm_atime; /* 最後に付加した時間 */
time_t shm_dtime; /* 最後に分離した時間 */
time_t shm_ctime; /* 最後に変更した時間 */
};
shm_perm 共有メモリ・セグメントへのアクセス許可を指定した ipc_perm 構
造体。
shm_segsz 共有メモリ・セグメントのバイト数。
shm_cpid 共有メモリ・セグメントを作成したプロセスの ID。
shm_lpid 最後に shmat(2) または shmdt(2) システム・コールを実行したプ
ロセスの ID。
shm_nattch この共有メモリ・セグメントをメモリに付加 (attach) しているプ
ロセスの数。
shm_atime 最後に shmat(2) システム・コールを行なった時間。
shm_dtime 最後に shmdt(2) システム・コールを行なった時間。
shm_ctime 最後に shmctl(2) システム・コールを行なって、 shmid_ds 構 造
体を変更した時間。
関連項目
ipc(2), msgctl(2), msgget(2), msgrcv(2), msgsnd(2), semctl(2),
semget(2), semop(2), shmat(2), shmctl(2), shmdt(2), shmget(2), ftok(3)
Linux 2009-01-26 SVIPC(7)
SVIPC(7) Linux Programmer’s Manual SVIPC(7)
NAME
svipc - System V interprocess communication mechanisms
SYNOPSIS
#include
#include
#include
#include
#include
DESCRIPTION
This manual page refers to the Linux implementation of the System V
interprocess communication (IPC) mechanisms: message queues, semaphore
sets, and shared memory segments. In the following, the word resource
means an instantiation of one among such mechanisms.
Resource Access Permissions
For each resource, the system uses a common structure of type struct
ipc_perm to store information needed in determining permissions to per-
form an IPC operation. The ipc_perm structure, defined by the
system header file, includes the following members:
struct ipc_perm {
uid_t cuid; /* creator user ID */
gid_t cgid; /* creator group ID */
uid_t uid; /* owner user ID */
gid_t gid; /* owner group ID */
unsigned short mode; /* r/w permissions */
};
The mode member of the 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:
0400 Read by user.
0200 Write by user.
0040 Read by group.
0020 Write by group.
0004 Read by others.
0002 Write by others.
Bits 0100, 0010, and 0001 (the execute bits) are unused by the system.
Furthermore, "write" effectively means "alter" for a semaphore set.
The same system header file also defines the following symbolic con-
stants:
IPC_CREAT Create entry if key doesn’t exist.
IPC_EXCL Fail if key exists.
IPC_NOWAIT Error if request must wait.
IPC_PRIVATE Private key.
IPC_RMID Remove resource.
IPC_SET Set resource options.
IPC_STAT Get resource options.
Note that IPC_PRIVATE is a key_t type, while all the other symbolic
constants are flag fields and can be OR’ed into an int type variable.
Message Queues
A message queue is uniquely identified by a positive integer (its
msqid) and has an associated data structure of type struct msqid_ds,
defined in , containing the following members:
struct msqid_ds {
struct ipc_perm msg_perm;
msgqnum_t msg_qnum; /* no of messages on queue */
msglen_t msg_qbytes; /* bytes max on a queue */
pid_t msg_lspid; /* PID of last msgsnd(2) call */
pid_t msg_lrpid; /* PID of last msgrcv(2) call */
time_t msg_stime; /* last msgsnd(2) time */
time_t msg_rtime; /* last msgrcv(2) time */
time_t msg_ctime; /* last change time */
};
msg_perm ipc_perm structure that specifies the access permissions on
the message queue.
msg_qnum Number of messages currently on the message queue.
msg_qbytes Maximum number of bytes of message text allowed on the mes-
sage queue.
msg_lspid ID of the process that performed the last msgsnd(2) system
call.
msg_lrpid ID of the process that performed the last msgrcv(2) system
call.
msg_stime Time of the last msgsnd(2) system call.
msg_rtime Time of the last msgrcv(2) system call.
msg_ctime Time of the last system call that changed a member of the
msqid_ds structure.
Semaphore Sets
A semaphore set is uniquely identified by a positive integer (its
semid) and has an associated data structure of type struct semid_ds,
defined in , containing the following members:
struct semid_ds {
struct ipc_perm sem_perm;
time_t sem_otime; /* last operation time */
time_t sem_ctime; /* last change time */
unsigned long sem_nsems; /* count of sems in set */
};
sem_perm ipc_perm structure that specifies the access permissions on
the semaphore set.
sem_otime Time of last semop(2) system call.
sem_ctime Time of last semctl(2) system call that changed a member of
the above structure or of one semaphore belonging to the
set.
sem_nsems Number of semaphores in the set. Each semaphore of the set
is referenced by a non-negative integer ranging from 0 to
sem_nsems-1.
A semaphore is a data structure of type struct sem containing the fol-
lowing members:
struct sem {
int semval; /* semaphore value */
int sempid; /* PID for last operation */
};
semval Semaphore value: a non-negative integer.
sempid ID of the last process that performed a semaphore operation
on this semaphore.
Shared Memory Segments
A shared memory segment is uniquely identified by a positive integer
(its shmid) and has an associated data structure of type struct
shmid_ds, defined in , containing the following members:
struct shmid_ds {
struct ipc_perm shm_perm;
size_t shm_segsz; /* size of segment */
pid_t shm_cpid; /* PID of creator */
pid_t shm_lpid; /* PID, last operation */
shmatt_t shm_nattch; /* no. of current attaches */
time_t shm_atime; /* time of last attach */
time_t shm_dtime; /* time of last detach */
time_t shm_ctime; /* time of last change */
};
shm_perm ipc_perm structure that specifies the access permissions on
the shared memory segment.
shm_segsz Size in bytes of the shared memory segment.
shm_cpid ID of the process that created the shared memory segment.
shm_lpid ID of the last process that executed a shmat(2) or shmdt(2)
system call.
shm_nattch Number of current alive attaches for this shared memory seg-
ment.
shm_atime Time of the last shmat(2) system call.
shm_dtime Time of the last shmdt(2) system call.
shm_ctime Time of the last shmctl(2) system call that changed
shmid_ds.
SEE ALSO
ipc(2), msgctl(2), msgget(2), msgrcv(2), msgsnd(2), semctl(2),
semget(2), semop(2), shmat(2), shmctl(2), shmdt(2), shmget(2), ftok(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2009-01-26 SVIPC(7)