.\" Copyright (c) 2012, Petr Benas .\" and Copyright (c) 2012, Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of .\" this manual under the conditions for verbatim copying, provided that .\" the entire resulting derived work is distributed under the terms of .\" a permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume .\" no responsibility for errors or omissions, or for damages resulting .\" from the use of the information contained herein. The author(s) may .\" not have taken the same level of care in the production of this .\" manual, which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2012 Akihiro MOTOKI .\" all rights reserved. .\" Translated 2012-05-31, Akihiro MOTOKI .\" .TH GET_NPROCS 3 2012\-03\-20 GNU "Linux Programmer's Manual" .SH 名前 get_nprocs, get_nprocs_conf \- プロセッサ数を取得する .SH 書式 \fB#include \fP .sp \fBint get_nprocs(void);\fP .br \fBint get_nprocs_conf(void);\fP .SH 説明 \fBget_nprocs_conf\fP() 関数は、オペレーティングシステムで 設定されているプロセッサ数を返す。 \fBget_nprocs\fP() 関数は、システムで現在利用可能なプロセッサ数を返す。 (例えば、ホットプラグが可能なシステムでは) オフラインになっているプロセッサがある場合があるので、 この数は \fBget_nprocs_conf\fP() が返す数より小さい場合がある。 .SH 返り値 「説明」の節で説明した通りである。 .SH 準拠 これらの関数は GNU による拡張である。 .SH 注意 .\" glibc 2.15 これらの関数の現在の実装はかなりコストがかかる実装になっている。 関数が呼ばれる度に \fI/sys\fP ファイルシステム内のファイルをオープンして 解析するようになっているからである。 以下の \fBsysconf\fP(3) の呼び出しで、このページに書かれている関数を使った 場合に返されるのと同じ情報を得ることができる。 .nf np = sysconf(_SC_NPROCESSORS_CONF); /* processors configured */ np = sysconf(_SC_NPROCESSORS_ONLN); /* processors available */ .fi .SH 例 以下の例は、 \fBget_nprocs\fP() と \fBget_nprocs_conf\fP() が どのように利用できるかを示すものである。 .nf #include #include int main(int argc, char *argv[]) { printf("This system has %d processors configured and " "%d processors available.\en", get_nprocs_conf(), get_nprocs()); return 0; } .fi .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。