OSDN Git Service

5d88205d55c4cbd4cf8074e46d0564a067ae3c48
[linuxjm/LDP_man-pages.git] / release / man7 / shm_overview.7
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
4 .\" Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
5 .\" <mtk.manpages@gmail.com>
6 .\"
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
10 .\"
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
15 .\"
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein.  The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
22 .\" professionally.
23 .\"
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
26 .\"
27 .\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
28 .\"         all rights reserved.
29 .\" Translated 2008-08-21, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.04
30 .\"
31 .TH SHM_OVERVIEW 7 2010-09-10 "Linux" "Linux Programmer's Manual"
32 .SH 名前
33 shm_overview \- POSIX 共有メモリの概要
34 .SH 説明
35 POSIX 共有メモリ API を使用すると、メモリのある領域を共有して、
36 プロセス間で情報をやり取りすることができる。
37
38 この API では以下のインターフェースが採用されている。
39 .TP 15
40 .BR shm_open (3)
41 新しいオブジェクトを生成しオープンする、もしくは
42 既存のオブジェクトをオープンする。これは
43 .BR open (2)
44 と同じである。下記にある他のインターフェースで使用する
45 ファイルディスクリプタを返す。
46 .TP
47 .BR ftruncate (2)
48 共有メモリオブジェクトの大きさを設定する。
49 .TP
50 .BR mmap (2)
51 呼び出したプロセスの仮想アドレス空間に共有メモリオブジェクトを
52 マップする。
53 .TP
54 .BR munmap (2)
55 呼び出したプロセスの仮想アドレス空間から
56 共有メモリオブジェクトをアンマップする。
57 .TP
58 .BR shm_unlink (3)
59 共有メモリオブジェクト名を削除する。
60 .TP
61 .BR close (2)
62 .BR shm_open (3)
63 で割り当てられたファイルディスクリプタが不要になった際に、
64 そのファイルディスクリプタをクローズする。
65 .TP
66 .BR fstat (2)
67 その共有メモリオブジェクトについての情報が入った
68 .I stat
69 構造体を取得する。
70 このシステムコールが返す情報には、オブジェクトのサイズ
71 .RI ( st_size )、
72 許可属性
73 .RI ( st_mode )、
74 所有者
75 .RI ( st_uid )、
76 グループ
77 .RI ( st_gid )
78 がある。
79 .TP
80 .BR fchown (2)
81 共有メモリオブジェクトの所有権を変更する。
82 .TP
83 .BR fchmod (2)
84 共有メモリオブジェクトの許可属性を変更する。
85 .SS バージョン
86 POSIX 共有メモリは Linux 2.4 と glibc 2.2 以降でサポートされている。
87 .SS 持続性
88 POSIX 共有メモリオブジェクトはカーネル内で保持される。
89 共有メモリオブジェクトは、システムがシャットダウンされるか、
90 全てのプロセスがそのオブジェクトをアンマップし、
91 .BR shm_unlink (3)
92 で削除されるまで、存在し続ける。
93 .SS リンク
94 POSIX 共有メモリ API を使用したプログラムは
95 .I cc \-lrt
96 でコンパイルし、リアルタイムライブラリ
97 .I librt
98 とリンクしなければならない。
99 .SS ファイルシステム経由での共有メモリオブジェクトへのアクセス
100 Linux では、共有メモリオブジェクトは通常
101 .I /dev/shm
102 以下にマウントされる仮想ファイルシステム
103 .RI ( tmpfs )
104 内に作成される。
105 カーネル 2.6.19 以降の Linux では、
106 仮想ファイルシステム内のオブジェクトの許可属性の制御に、
107 アクセス制御リスト (ACL; access control lists) を使うことができる。
108 .SH 準拠
109 POSIX.1-2001.
110 .SH 注意
111 通常は、共有メモリオブジェクトにアクセスするプロセスは、
112 POSIX セマフォなどを使ってプロセス間で同期をとらなければならない。
113
114 System V 共有メモリ
115 .RB ( shmget (2),
116 .BR shmop (2)
117 など) は古い共有メモリ API である。
118 POSIX 共有メモリは、より簡単で、うまく設計されたインタフェースを提供している。
119 一方で、POSIX 共有メモリは System V 共有メモリと比べると
120 利用できるシステムが少ない (特に、古いシステムでは少ない)。
121 .SH 関連項目
122 .BR fchmod (2),
123 .BR fchown (2),
124 .BR fstat (2),
125 .BR ftruncate (2),
126 .BR mmap (2),
127 .BR mprotect (2),
128 .BR munmap (2),
129 .BR shmget (2),
130 .BR shmop (2),
131 .BR shm_open (3),
132 .BR shm_unlink (3),
133 .BR sem_overview (7)