1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) Markus Kuhn, 1996
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, write to the Free
22 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
25 .\" 1995-11-26 Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>
26 .\" First version written
28 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
29 .\" all rights reserved.
30 .\" Translated Sun Feb 23 16:33:31 JST 1997
31 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
32 .\" Updated & Modified Fri May 21 03:32:57 JST 2004
33 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
41 .\"WORD: segment セグメント
43 .\"WORD: shared memory 共有メモリ
45 .\"WORD: real-time リアル・タイム
46 .\"WORD: algorithm アルゴリズム
47 .\"WORD: security セキュリティ
48 .\"WORD: scheduling スケジューリング
49 .\"WORD: password パスワード
50 .\"WORD: secret key 秘密鍵
51 .\"WORD: heap ヒープ(heap)
52 .\"WORD: automatic variable 自動変数
53 .\"WORD: copy-on-write 書き込み時コピー
55 .\"WORD: root スーパー・ユーザー
57 .TH MLOCKALL 2 1995-11-26 "Linux 1.3.43" "Linux Programmer's Manual"
60 .\"O mlockall \- disable paging for calling process
61 mlockall \- 呼び出したプロセスのページングを禁止する
65 .B #include <sys/mman.h>
67 \fBint mlockall(int \fIflags\fB);
72 .\"O disables paging for all pages mapped into the address space of the
73 .\"O calling process. This includes the pages of the code, data and stack
74 .\"O segment, as well as shared libraries, user space kernel data, shared
75 .\"O memory and memory mapped files. All mapped pages are guaranteed to be
76 .\"O resident in RAM when the
78 .\"O system call returns successfully and they are guaranteed to stay in RAM
79 .\"O until the pages are unlocked again by
83 .\"O or until the process terminates or starts another program with
86 呼び出したプロセスのアドレス空間にマップされている全てのページの
87 ページング (paging) を禁止する。これにはコード、データ、スタックの
88 各セグメント、共有ライブラリ、カーネルのユーザー空間データ、
89 共有メモリ、メモリ・マップされたファイルを含んでいる。
91 システム・コールが成功した場合には全てのマップされたページは RAM に
96 によってページがアンロックされたり、プロセスが終了したり、
98 によって他のプログラムを開始したりするまでは RAM に残ることが
100 .\"O Child processes do not inherit page locks across a
103 を行なった場合に子プロセスはページのロックを継承しない。
105 .\"O Memory locking has two main applications: real-time algorithms and
106 .\"O high-security data processing. Real-time applications require
107 .\"O deterministic timing, and, like scheduling, paging is one major cause
108 .\"O of unexpected program execution delays. Real-time applications will
109 .\"O usually also switch to a real-time scheduler with
110 .\"O .BR sched_setscheduler .
111 メモリのロックには主に二つの使い道がある。リアル・タイム (real-time)
112 アルゴリズムと高いセキュリティのデータ処理である。リアル・タイムの
113 アプリケーションは決定的なタイミングやスケジューリングを要求し、
114 ページングは予期しないプログラムの実行遅れをもたらす重要な要因である。
115 リアル・タイムのアプリケーションはたいていは
116 .BR sched_setscheduler
117 でリアル・タイム・スケジュラーに変更される。
118 .\"O Cryptographic security software often handles critical bytes like
119 .\"O passwords or secret keys as data structures. As a result of paging,
120 .\"O these secrets could be transfered onto a persistent swap store medium,
121 .\"O where they might be accessible to the enemy long after the security
122 .\"O software has erased the secrets in RAM and terminated. For security
123 .\"O applications, only small parts of memory have to be locked, for which
126 暗号やセキュリティのソフトウェアはしばしばパスワードや秘密鍵のデータの
127 ような重要なバイトを扱う。ページングの結果、これらの秘密が
128 スワップ用の固定媒体に転送されるかもしれない。そしてそれはセキュリティ
129 ・ソフトウェアが RAM 上の秘密を削除して終了したずっと後にでも敵によって
130 アクセスが可能になるかもしれない。セキュリティ・アプリケーションでは
131 メモリのほんの小さな部分のみがロックされなければならない。そのために
137 .\"O parameter can be constructed from the bitwise OR of the following
140 パラメーターは以下の内容のビット OR からなる:
143 .\"O Lock all pages which are currently mapped into the address space of
145 現在、プロセスのアドレス空間にマップされている全てのページをロックする。
148 .\"O Lock all pages which will become mapped into the address space of the
149 .\"O process in the future. These could be for instance new pages required
150 .\"O by a growing heap and stack as well as new memory mapped files or
151 .\"O shared memory regions.
152 将来、プロセスのアドレス空間にマップされる全てのページをロックする。
153 これは例えば、成長するヒープ (heap) やスタックの他に
154 新しいメモリ・マップされたファイルや共有メモリ領域などに必要となる。
158 .\"O has been specified and the number of locked pages exceeds the upper
159 .\"O limit of allowed locked pages, then the system call which caused the
160 .\"O new mapping will fail with
163 が指定されており、ロックされたページの数がロックすることができるページ数の
164 上限を超えた場合には、新しくページをマップするシステム・コールは
167 .\"O If these new pages have been mapped by the the growing stack, then the
168 .\"O kernel will deny stack expansion and send a
170 成長するスタックによって新しいページがマップされる場合は、カーネルは
175 .\"O Real-time processes should reserve enough locked stack pages before
176 .\"O entering the time-critical section, so that no page fault can be
177 .\"O caused by function calls. This can be achieved by calling a function
178 .\"O which has a sufficiently large automatic variable and which writes to
179 .\"O the memory occupied by this large array in order to touch these stack
180 .\"O pages. This way, enough pages will be mapped for the stack and can be
181 .\"O locked into RAM. The dummy writes ensure that not even copy-on-write
182 .\"O page faults can occur in the critical section.
183 リアル・タイム・プロセスは関数呼び出しでページ・フォールトが発生しない
184 ように時間が致命的な部分に入る前に十分なロックされたスタックを確保して
185 おく必要がある。これは十分に大きな自動変数を確保する関数を呼び出し、
186 これらのスタック用のページがメモリに確保されるようにこの大きな配列に
187 書き込みを行なうことによって達成できる。この方法によって十分なページが
188 スタックにマップされ、RAM にロックされる。ダミーの書き込みは致命的な
189 部分で書き込み時コピー (copy-on-write) によるページ・フォールトさえ
192 .\"O Memory locks do not stack, i.e., pages which have been locked several times
197 .\"O will be unlocked by a single call to
198 .\"O .BR munlockall .
199 メモリのロック (lock) は累積しない。例えば複数回
205 によってアンロック (unlock) される。
206 .\"O Pages which are mapped to several locations or by several processes stay
207 .\"O locked into RAM as long as they are locked at least at one location or by
208 .\"O at least one process.
209 複数の場所や複数のプロセスにマップされているページは、少なくとも一つの場所、
210 一つのプロセスでロックされている限りは RAM に残り続ける。
211 .\"O .SH "RETURN VALUE"
215 .\"O returns zero. On error, \-1 is returned, and
217 .\"O is set appropriately.
220 はゼロを返す。エラーの場合は、\-1 が返され、
227 .\"O The process tried to exceed the maximum number of allowed locked
229 許される上限を超える数のページをロックしようとした。
232 .\"O The calling process does not have appropriate privileges. Only root
233 .\"O processes are allowed to lock pages.
234 呼び出したプロセスが適切な特権を所有していない。
235 スーパー・ユーザーのプロセスのみがページをロックすることができる。
238 .\"O Unknown flags were specified.
240 .\"O .SH AVAILABILITY
242 .\"O On POSIX systems on which
247 .\"O .B _POSIX_MEMLOCK
248 .\"O is defined in <unistd.h> to a value greater than 0. (See also
249 .\"O .BR sysconf (3).)
259 .\"O .\" POSIX 1003.1-2001: It shall be defined to -1 or 0 or 200112L.
260 .\"O .\" -1: unavailable, 0: ask using sysconf().
261 .\"O .\" glibc defines it to 1.
262 .\" POSIX 1003.1-2001 では、この値を -1, 0, 200112L の
264 .\" -1 は使用不可、0 は sysconf() を使って尋ねるという意味である。
265 .\" glibc では、この値を 1 としている。
266 .\"O .SH "CONFORMING TO"
268 .\"O POSIX.1b, SVr4. SVr4 documents an additional EAGAIN error code.
269 POSIX.1b, SVR4. SVr4 には他に EAGAIN エラーについての記述がある。