1 .\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Wed Jul 28 10:57:35 1993, Rik Faith <faith@cs.unc.edu>
24 .\" Modified Sun Nov 28 16:43:30 1993, Rik Faith <faith@cs.unc.edu>
25 .\" with material from Giorgio Ciucci <giorgio@crcc.it>
26 .\" Portions Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
27 .\" Modified Tue Oct 22 22:03:17 1996 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified, 8 Jan 2003, Michael Kerrisk, <mtk.manpages@gmail.com>
29 .\" Removed EIDRM from errors - that can't happen...
30 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\" Added notes on capability requirements
32 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" Language and formatting clean-ups
34 .\" Added notes on /proc files
36 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
37 .\" all rights reserved.
38 .\" Translated 1997-03-01, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
39 .\" Updated & Modified 2001-06-03, Yuichi SATO <ysato@h4.dion.ne.jp>
40 .\" Updated 2001-12-22, Kentaro Shirakata <argrath@ub32.org>
41 .\" Updated 2002-10-16, Kentaro Shirakata <argrath@ub32.org>
42 .\" Updated 2003-02-23, Kentaro Shirakata <argrath@ub32.org>
43 .\" Updated 2005-03-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2005-11-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
45 .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
47 .\"WORD: shared memory 共有メモリ
48 .\"WORD: segment セグメント
53 .\"WORD: super-user スーパー・ユーザー
56 .\"WORD: identifier 識別子
58 .\"WORD: effective user ID 実効ユーザーID
59 .\"WORD: effective group ID 実効グループID
63 .TH SHMGET 2 2006-05-02 "Linux" "Linux Programmer's Manual"
66 .\"O shmget \- allocates a shared memory segment
67 shmget \- 共有メモリ・セグメントを割り当てる
71 .B #include <sys/ipc.h>
73 .B #include <sys/shm.h>
75 .BI "int shmget(key_t " key ", size_t " size ", int " shmflg );
80 .\"O returns the identifier of the shared memory segment
81 .\"O associated with the value of the argument
83 .\"O A new shared memory segment, with size equal to the value of
85 .\"O rounded up to a multiple of
94 .\"O .BR IPC_PRIVATE ,
95 .\"O no shared memory segment corresponding to
104 引き数に対応する共有メモリ・セグメントの識別子を返す。
110 に対応する共有メモリ・セグメントが存在せず、
120 の倍数へと切り上げた (round up) 大きさとなる。
128 .\"O and a shared memory segment already exists for
136 .\"O (This is analogous to the effect of the combination
137 .\"O .B O_CREAT | O_EXCL
147 に対応する共有メモリ・セグメントが既に存在すると、
166 .\"O to create a new segment.
167 .\"O If this flag is not used, then
169 .\"O will find the segment associated with \fIkey\fP and check to see if
170 .\"O the user has permission to access the segment.
171 新しいセグメントを作成する。このフラグが指定されなかった場合、
173 は \fIkey\fP に対応するセグメントを探し、
174 ユーザがそのセグメントにアクセスする許可があるかどうかをチェックする。
177 .\"O used with \fBIPC_CREAT\fP to ensure failure if the segment already exists.
178 \fBIPC_CREAT\fP と共に使用し、セグメントが既に存在した場合には
182 .\"O (least significant 9 bits)
184 .\"O specifying the permissions granted to the owner, group, and world.
185 .\"O These bits have the same format, and the same
190 .\"O Presently, the execute permissions are not used by the system.
191 所有者、グループ、他人 (world) への許可を指定する。
197 今のところ、システムは実行 (execute) 許可を参照しない。
199 .\"O .BR SHM_HUGETLB " (since Linux 2.6)"
200 .BR SHM_HUGETLB " (Linux 2.6 以降)"
201 .\"O Allocate the segment using "huge pages."
202 .\"O See the kernel source file
203 .\"O .I Documentation/vm/hugetlbpage.txt
204 .\"O for further information.
205 "ヒュージページ (huge page)" を使うセグメントを割り当てる。
207 .I Documentation/vm/hugetlbpage.txt
210 .\"O .BR SHM_NORESERVE " (since Linux 2.6.15)"
211 .BR SHM_NORESERVE " (Linux 2.6.15 以降)"
212 .\"O This flag serves the same purpose as the
214 .\"O .B MAP_NORESERVE
221 .\"O Do not reserve swap space for this segment.
222 .\"O When swap space is reserved, one has the guarantee
223 .\"O that it is possible to modify the segment.
224 .\"O When swap space is not reserved one might get
227 .\"O if no physical memory is available.
228 このセグメントに対するスワップ空間の予約を行わない。
229 スワップ空間を予約した場合は、そのセグメントの変更が必ず成功することが
230 保証される。スワップ空間の予約を行わなかった場合は、物理メモリに空きが
234 .\"O See also the discussion of the file
235 .\"O .I /proc/sys/vm/overcommit_memory
240 .I /proc/sys/vm/overcommit_memory
242 .\" As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
245 .\"O When a new shared memory segment is created,
246 .\"O its contents are initialized to zero values, and
247 .\"O its associated data structure,
250 .\"O .BR shmctl (2)),
251 .\"O is initialized as follows:
252 共有メモリ・セグメントが新たに作成される際、
253 共有メモリ・セグメントの内容は 0 で初期化され、
258 .\"O .I shm_perm.cuid
261 .\"O are set to the effective user ID of the calling process.
265 に呼び出し元プロセスの実効 (effective) ユーザーID を設定する。
267 .\"O .I shm_perm.cgid
270 .\"O are set to the effective group ID of the calling process.
274 に呼び出し元プロセスの実効グループID を設定する。
276 .\"O The least significant 9 bits of
277 .\"O .I shm_perm.mode
278 .\"O are set to the least significant 9 bit of
286 .\"O is set to the value of
294 .\"O .IR shm_nattch ,
306 .\"O is set to the current time.
310 .\"O If the shared memory segment already exists, the permissions are
311 .\"O verified, and a check is made to see if it is marked for destruction.
312 共有メモリ・セグメントが既に存在する場合、アクセス許可の検査と、
313 破壊 (destruction) マークがつけられていないかのチェックが行われる。
314 .\"O .SH "RETURN VALUE"
316 .\"O A valid segment identifier,
318 .\"O is returned on success, \-1 on error.
321 が返される。エラーの場合、 \-1 が返される。
326 .\"O is set to one of the following:
332 .\"O The user does not have permission to access the
333 .\"O shared memory segment, and does not have the
334 .\"O .B CAP_IPC_OWNER
336 ユーザーはその共有メモリ・セグメントへのアクセス許可を持たず、
341 .\"O .B IPC_CREAT | IPC_EXCL
342 .\"O was specified and the segment exists.
343 .B IPC_CREAT | IPC_EXCL
344 が指定されていたが、そのセグメントが既に存在する。
347 .\"O A new segment was to be created and \fIsize\fP < \fBSHMMIN\fP
348 .\"O or \fIsize\fP > \fBSHMMAX\fP, or no new segment was to be created,
349 .\"O a segment with given key existed, but \fIsize\fP is greater than the size
350 .\"O of that segment.
352 \fIsize\fP < \fBSHMMIN\fP または \fIsize\fP > \fBSHMMAX\fP であった。
353 もしくは、指定されたキーに対応するセグメントが既に存在して、新しい
354 セグメントを作成しようとはしなかったが、\fIsize\fP が存在するセグメントの
358 .\"O .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
359 .\"O The system limit on the total number of open files has been reached.
360 .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
361 システム全体でオープンされているファイルの総数が上限に達した。
364 .\"O No segment exists for the given \fIkey\fP, and
366 .\"O was not specified.
367 指定された \fIkey\fP に対応するセグメントが存在せず、
372 .\"O No memory could be allocated for segment overhead.
373 セグメントの管理情報 (overhead) に割り当てるメモリがなかった。
376 .\"O All possible shared memory ID's have been taken
378 .\"O or allocating a segment of the requested
380 .\"O would cause the system to exceed the system-wide limit on shared memory
382 .\" motoki 2005-03-02 -- SHMMNI の意味を考慮して意訳
383 システム全体の共有メモリ・セグメント数の制限
395 .\"O flag was specified, but the caller was not privileged (did not have the
399 フラグが指定されたが、呼び出し元には権限がなかった
402 .\"O .SH "CONFORMING TO"
405 .\"O .\" SVr4 documents an additional error condition EEXIST.
406 .\" SVr4 には追加で EEXIST エラー状態の記述がある。
409 .\"O is a nonportable Linux extension.
411 は Linux での拡張であり、移植性はない。
415 .\"O isn't a flag field but a
422 .\"O If this special value is used for
424 .\"O the system call ignores everything but the least significant 9 bits of
426 .\"O and creates a new shared memory segment (on success).
434 (成功すれば) 新しい共有メモリ・セグメントを作成する。
436 .\"O The following limits on shared memory segment resources affect the
440 コールに影響する共有メモリ・セグメント資源の制限は以下の通りである:
443 .\"O System wide maximum of shared memory pages
444 .\"O (on Linux, this limit can be read and modified via
445 .\"O .IR /proc/sys/kernel/shmall ).
448 .I /proc/sys/kernel/shmall
452 .\"O Maximum size in bytes for a shared memory segment: policy dependent
453 .\"O (on Linux, this limit can be read and modified via
454 .\"O .IR /proc/sys/kernel/shmmax ).
455 共有メモリ・セグメントのバイト単位の大きさの上限: 方針依存
457 .I /proc/sys/kernel/shmmax
461 .\"O Minimum size in bytes for a shared memory segment: implementation
462 .\"O dependent (currently 1 byte, though
464 .\"O is the effective minimum size).
465 共有メモリ・セグメントのバイト単位の大きさの下限: 実装依存
466 (現在は 1 バイトだが、実質的な最小サイズは
471 .\"O System wide maximum number of shared memory segments: implementation
472 .\"O dependent (currently 4096, was 128 before Linux 2.3.99;
473 .\"O on Linux, this limit can be read and modified via
474 .\"O .IR /proc/sys/kernel/shmmni ).
475 .\"O .\" Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
476 .\"O .\" that we could create one more segment than SHMMNI -- MTK
477 .\"O .\" This /proc file is not available in Linux 2.2 and earlier -- MTK
478 システム全体の共有メモリーの数の上限: 実装依存
479 (現在は 4096。Linux 2.3.99 より前では 128。
481 .I /proc/sys/kernel/shmmni
483 .\" 2.4.x と 2.6.8 の間のカーネルには、SHMMNI より一つの多くの
484 .\" セグメントを作成できるというバグがあった。
485 .\" この /proc ファイルは Linux 2.2 以前では利用できない -- MTK
487 .\"O The implementation has no specific limits for the per-process maximum
488 .\"O number of shared memory segments
490 プロセス当りの共有メモリ・セグメントの個数の最大値
494 .\"O Until version 2.3.30 Linux would return
498 .\"O on a shared memory segment scheduled for deletion.
500 バージョン 2.3.30 までは、Linux は
501 削除が予定されている共有メモリ・セグメントに対して
510 .\"O was perhaps unfortunate,
512 .\"O would more clearly show its function.
514 という名前を選んだのはおそらく失敗であろう。
516 の方がより明確にその機能を表しているだろう。
523 .BR capabilities (7),
524 .BR shm_overview (7),