.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (C) Markus Kuhn, 1996 .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" 1995-11-26 Markus Kuhn .\" First version written .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Sun Feb 23 16:33:31 JST 1997 .\" by HANATAKA Shinya .\" Updated & Modified Fri May 21 03:32:57 JST 2004 .\" by Yuichi SATO .\" .\"WORD: lock ロック .\"WORD: process プロセス .\"WORD: paging ページング .\"WORD: code コード .\"WORD: data データ .\"WORD: stack スタック .\"WORD: segment セグメント .\"WORD: kernel カーネル .\"WORD: shared memory 共有メモリ .\"WORD: unlock アンロック .\"WORD: real-time リアル・タイム .\"WORD: algorithm アルゴリズム .\"WORD: security セキュリティ .\"WORD: scheduling スケジューリング .\"WORD: password パスワード .\"WORD: secret key 秘密鍵 .\"WORD: heap ヒープ(heap) .\"WORD: automatic variable 自動変数 .\"WORD: copy-on-write 書き込み時コピー .\"WORD: flag フラグ .\"WORD: root スーパー・ユーザー .\" .TH MLOCKALL 2 1995-11-26 "Linux 1.3.43" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O mlockall \- disable paging for calling process mlockall \- 呼び出したプロセスのページングを禁止する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp \fBint mlockall(int \fIflags\fB); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O .B mlockall .\"O disables paging for all pages mapped into the address space of the .\"O calling process. This includes the pages of the code, data and stack .\"O segment, as well as shared libraries, user space kernel data, shared .\"O memory and memory mapped files. All mapped pages are guaranteed to be .\"O resident in RAM when the .\"O .B mlockall .\"O system call returns successfully and they are guaranteed to stay in RAM .\"O until the pages are unlocked again by .\"O .B munlock .\"O or .\"O .B munlockall .\"O or until the process terminates or starts another program with .\"O .BR exec . .B mlockall 呼び出したプロセスのアドレス空間にマップされている全てのページの ページング (paging) を禁止する。これにはコード、データ、スタックの 各セグメント、共有ライブラリ、カーネルのユーザー空間データ、 共有メモリ、メモリ・マップされたファイルを含んでいる。 .B mlockall システム・コールが成功した場合には全てのマップされたページは RAM に 残り続けることを保証される、そして .B munlock や .B munlockall によってページがアンロックされたり、プロセスが終了したり、 .BR exec によって他のプログラムを開始したりするまでは RAM に残ることが 保証される。 .\"O Child processes do not inherit page locks across a .\"O .BR fork . .BR fork を行なった場合に子プロセスはページのロックを継承しない。 .\"O Memory locking has two main applications: real-time algorithms and .\"O high-security data processing. Real-time applications require .\"O deterministic timing, and, like scheduling, paging is one major cause .\"O of unexpected program execution delays. Real-time applications will .\"O usually also switch to a real-time scheduler with .\"O .BR sched_setscheduler . メモリのロックには主に二つの使い道がある。リアル・タイム (real-time) アルゴリズムと高いセキュリティのデータ処理である。リアル・タイムの アプリケーションは決定的なタイミングやスケジューリングを要求し、 ページングは予期しないプログラムの実行遅れをもたらす重要な要因である。 リアル・タイムのアプリケーションはたいていは .BR sched_setscheduler でリアル・タイム・スケジュラーに変更される。 .\"O Cryptographic security software often handles critical bytes like .\"O passwords or secret keys as data structures. As a result of paging, .\"O these secrets could be transfered onto a persistent swap store medium, .\"O where they might be accessible to the enemy long after the security .\"O software has erased the secrets in RAM and terminated. For security .\"O applications, only small parts of memory have to be locked, for which .\"O .B mlock .\"O is available. 暗号やセキュリティのソフトウェアはしばしばパスワードや秘密鍵のデータの ような重要なバイトを扱う。ページングの結果、これらの秘密が スワップ用の固定媒体に転送されるかもしれない。そしてそれはセキュリティ ・ソフトウェアが RAM 上の秘密を削除して終了したずっと後にでも敵によって アクセスが可能になるかもしれない。セキュリティ・アプリケーションでは メモリのほんの小さな部分のみがロックされなければならない。そのために .B mlock が使用できる。 .\"O The .\"O .I flags .\"O parameter can be constructed from the bitwise OR of the following .\"O constants: .I flags パラメーターは以下の内容のビット OR からなる: .TP 1.2i .B MCL_CURRENT .\"O Lock all pages which are currently mapped into the address space of .\"O the process. 現在、プロセスのアドレス空間にマップされている全てのページをロックする。 .TP .B MCL_FUTURE .\"O Lock all pages which will become mapped into the address space of the .\"O process in the future. These could be for instance new pages required .\"O by a growing heap and stack as well as new memory mapped files or .\"O shared memory regions. 将来、プロセスのアドレス空間にマップされる全てのページをロックする。 これは例えば、成長するヒープ (heap) やスタックの他に 新しいメモリ・マップされたファイルや共有メモリ領域などに必要となる。 .PP .\"O If .\"O .B MCL_FUTURE .\"O has been specified and the number of locked pages exceeds the upper .\"O limit of allowed locked pages, then the system call which caused the .\"O new mapping will fail with .\"O .BR ENOMEM . .B MCL_FUTURE が指定されており、ロックされたページの数がロックすることができるページ数の 上限を超えた場合には、新しくページをマップするシステム・コールは .BR ENOMEM となって失敗する。 .\"O If these new pages have been mapped by the the growing stack, then the .\"O kernel will deny stack expansion and send a .\"O .BR SIGSEGV . 成長するスタックによって新しいページがマップされる場合は、カーネルは スタックの拡張を拒否し、 .BR SIGSEGV を送る。 .\"O Real-time processes should reserve enough locked stack pages before .\"O entering the time-critical section, so that no page fault can be .\"O caused by function calls. This can be achieved by calling a function .\"O which has a sufficiently large automatic variable and which writes to .\"O the memory occupied by this large array in order to touch these stack .\"O pages. This way, enough pages will be mapped for the stack and can be .\"O locked into RAM. The dummy writes ensure that not even copy-on-write .\"O page faults can occur in the critical section. リアル・タイム・プロセスは関数呼び出しでページ・フォールトが発生しない ように時間が致命的な部分に入る前に十分なロックされたスタックを確保して おく必要がある。これは十分に大きな自動変数を確保する関数を呼び出し、 これらのスタック用のページがメモリに確保されるようにこの大きな配列に 書き込みを行なうことによって達成できる。この方法によって十分なページが スタックにマップされ、RAM にロックされる。ダミーの書き込みは致命的な 部分で書き込み時コピー (copy-on-write) によるページ・フォールトさえ 起きないことを保証する。 .\"O Memory locks do not stack, i.e., pages which have been locked several times .\"O by calls to .\"O .B mlockall .\"O or .\"O .B mlock .\"O will be unlocked by a single call to .\"O .BR munlockall . メモリのロック (lock) は累積しない。例えば複数回 .B mlock や .B mlockall を呼び出してロックされたページも一回の .BR munlockall によってアンロック (unlock) される。 .\"O Pages which are mapped to several locations or by several processes stay .\"O locked into RAM as long as they are locked at least at one location or by .\"O at least one process. 複数の場所や複数のプロセスにマップされているページは、少なくとも一つの場所、 一つのプロセスでロックされている限りは RAM に残り続ける。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, .\"O .B mlockall .\"O returns zero. On error, \-1 is returned, and .\"O .I errno .\"O is set appropriately. 成功した場合は、 .B mlockall はゼロを返す。エラーの場合は、\-1 が返され、 .I errno が適切に設定される。 .\"O .SH ERRORS .SH エラー .TP .B ENOMEM .\"O The process tried to exceed the maximum number of allowed locked .\"O pages. 許される上限を超える数のページをロックしようとした。 .TP .B EPERM .\"O The calling process does not have appropriate privileges. Only root .\"O processes are allowed to lock pages. 呼び出したプロセスが適切な特権を所有していない。 スーパー・ユーザーのプロセスのみがページをロックすることができる。 .TP .B EINVAL .\"O Unknown flags were specified. 未知のフラグが指定された。 .\"O .SH AVAILABILITY .SH 有効性 .\"O On POSIX systems on which .\"O .B mlockall .\"O and .\"O .B munlockall .\"O are available, .\"O .B _POSIX_MEMLOCK .\"O is defined in to a value greater than 0. (See also .\"O .BR sysconf (3).) .B mlockall と .B munlockall が利用可能な POSIX システムでは、 において .B _POSIX_MEMLOCK が 0 より大きい値に定義されている .RB ( sysconf (3) を参照すること)。 .\"O .\" POSIX 1003.1-2001: It shall be defined to -1 or 0 or 200112L. .\"O .\" -1: unavailable, 0: ask using sysconf(). .\"O .\" glibc defines it to 1. .\" POSIX 1003.1-2001 では、この値を -1, 0, 200112L の .\" どれかに定義すべきとしている。 .\" -1 は使用不可、0 は sysconf() を使って尋ねるという意味である。 .\" glibc では、この値を 1 としている。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O POSIX.1b, SVr4. SVr4 documents an additional EAGAIN error code. POSIX.1b, SVR4. SVr4 には他に EAGAIN エラーについての記述がある。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR munlockall (2), .BR mlock (2), .BR munlock (2), .BR sysconf (3)