OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / get_nprocs_conf.3
1 .\" Copyright (c) 2012, Petr Benas
2 .\" and Copyright (c) 2012, Michael Kerrisk <mtk.man-pages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of
10 .\" this manual under the conditions for verbatim copying, provided that
11 .\" the entire resulting derived work is distributed under the terms of
12 .\" a permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume
16 .\" no responsibility for errors or omissions, or for damages resulting
17 .\" from the use of the information contained herein.  The author(s) may
18 .\" not have taken the same level of care in the production of this
19 .\" manual, which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH GET_NPROCS 3   2012-03-20 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 get_nprocs, get_nprocs_conf \- get number of processors
29 .SH SYNOPSIS
30 .B #include <sys/sysinfo.h>
31 .sp
32 .BI "int get_nprocs(void);"
33 .br
34 .BI "int get_nprocs_conf(void);"
35 .SH DESCRIPTION
36 The function
37 .BR get_nprocs_conf ()
38 returns the number of processors configured by the operating system.
39
40 The function
41 .BR get_nprocs ()
42 returns the number of processors currently available in the system.
43 This may be less than the number returned by
44 .BR get_nprocs_conf ()
45 because processors may be offline (e.g., on hotpluggable systems).
46 .SH RETURN VALUE
47 As given in DESCRIPTION.
48 .SH CONFORMING TO
49 These functions are GNU extensions.
50 .SH NOTES
51 The current
52 .\" glibc 2.15
53 implementation of these functions is rather expensive,
54 since they open and parse files in the
55 .I /sys
56 filesystem each time they are called.
57
58 The following
59 .BR sysconf (3)
60 calls make use of the functions documented on this page
61 to return the same information.
62 .nf
63
64     np = sysconf(_SC_NPROCESSORS_CONF);     /* processors configured */
65     np = sysconf(_SC_NPROCESSORS_ONLN);     /* processors available */
66 .fi
67 .SH EXAMPLE
68 The following example shows how
69 .BR get_nprocs ()
70 and
71 .BR get_nprocs_conf ()
72 can be used.
73
74 .nf
75 #include <stdio.h>
76 #include <sys/sysinfo.h>
77
78 int
79 main(int argc, char *argv[])
80 {
81     printf("This system has %d processors configured and "
82             "%d processors available.\\n",
83             get_nprocs_conf(), get_nprocs());
84     return 0;
85 }
86 .fi
87
88 .SH COLOPHON
89 This page is part of release 3.79 of the Linux
90 .I man-pages
91 project.
92 A description of the project,
93 information about reporting bugs,
94 and the latest version of this page,
95 can be found at
96 \%http://www.kernel.org/doc/man\-pages/.