mount_setattr.2: Reword the description of the 'propagation field'
[man-pages.git] / man3 / get_nprocs_conf.3
blob8bee44d32272c4f15ff01207fbc00535ea98f97a
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   2021-03-22 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 get_nprocs, get_nprocs_conf \- get number of processors
29 .SH SYNOPSIS
30 .nf
31 .B #include <sys/sysinfo.h>
32 .PP
33 .BI "int get_nprocs(void);"
34 .BI "int get_nprocs_conf(void);"
35 .fi
36 .SH DESCRIPTION
37 The function
38 .BR get_nprocs_conf ()
39 returns the number of processors configured by the operating system.
40 .PP
41 The function
42 .BR get_nprocs ()
43 returns the number of processors currently available in the system.
44 This may be less than the number returned by
45 .BR get_nprocs_conf ()
46 because processors may be offline (e.g., on hotpluggable systems).
47 .SH RETURN VALUE
48 As given in DESCRIPTION.
49 .SH ATTRIBUTES
50 For an explanation of the terms used in this section, see
51 .BR attributes (7).
52 .ad l
53 .nh
54 .TS
55 allbox;
56 lbx lb lb
57 l l l.
58 Interface       Attribute       Value
60 .BR get_nprocs (),
61 .BR get_nprocs_conf ()
62 T}      Thread safety   MT-Safe
63 .TE
64 .hy
65 .ad
66 .sp 1
67 .SH CONFORMING TO
68 These functions are GNU extensions.
69 .SH NOTES
70 The current
71 .\" glibc 2.15
72 implementation of these functions is rather expensive,
73 since they open and parse files in the
74 .I /sys
75 filesystem each time they are called.
76 .PP
77 The following
78 .BR sysconf (3)
79 calls make use of the functions documented on this page
80 to return the same information.
81 .PP
82 .in +4n
83 .EX
84 np = sysconf(_SC_NPROCESSORS_CONF);     /* processors configured */
85 np = sysconf(_SC_NPROCESSORS_ONLN);     /* processors available */
86 .EE
87 .in
88 .SH EXAMPLES
89 The following example shows how
90 .BR get_nprocs ()
91 and
92 .BR get_nprocs_conf ()
93 can be used.
94 .PP
95 .EX
96 #include <stdlib.h>
97 #include <stdio.h>
98 #include <sys/sysinfo.h>
101 main(int argc, char *argv[])
103     printf("This system has %d processors configured and "
104             "%d processors available.\en",
105             get_nprocs_conf(), get_nprocs());
106     exit(EXIT_SUCCESS);
109 .SH SEE ALSO
110 .BR nproc (1)