]> git.ipfire.org Git - thirdparty/man-pages.git/blame_incremental - man3/get_nprocs_conf.3
dist.mk, All pages: .TH: Generate date at 'make dist'
[thirdparty/man-pages.git] / man3 / get_nprocs_conf.3
... / ...
CommitLineData
1.\" Copyright (c) 2012, Petr Benas
2.\" and Copyright (c) 2012, Michael Kerrisk <mtk.man-pages@gmail.com>
3.\"
4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
5.\"
6.TH GET_NPROCS 3 (date) "Linux man-pages (unreleased)"
7.SH NAME
8get_nprocs, get_nprocs_conf \- get number of processors
9.SH LIBRARY
10Standard C library
11.RI ( libc ", " \-lc )
12.SH SYNOPSIS
13.nf
14.B #include <sys/sysinfo.h>
15.PP
16.B int get_nprocs(void);
17.B int get_nprocs_conf(void);
18.fi
19.SH DESCRIPTION
20The function
21.BR get_nprocs_conf ()
22returns the number of processors configured by the operating system.
23.PP
24The function
25.BR get_nprocs ()
26returns the number of processors currently available in the system.
27This may be less than the number returned by
28.BR get_nprocs_conf ()
29because processors may be offline (e.g., on hotpluggable systems).
30.SH RETURN VALUE
31As given in DESCRIPTION.
32.SH ATTRIBUTES
33For an explanation of the terms used in this section, see
34.BR attributes (7).
35.ad l
36.nh
37.TS
38allbox;
39lbx lb lb
40l l l.
41Interface Attribute Value
42T{
43.BR get_nprocs (),
44.BR get_nprocs_conf ()
45T} Thread safety MT-Safe
46.TE
47.hy
48.ad
49.sp 1
50.SH STANDARDS
51These functions are GNU extensions.
52.SH NOTES
53The current
54.\" glibc 2.15
55implementation of these functions is rather expensive,
56since they open and parse files in the
57.I /sys
58filesystem each time they are called.
59.PP
60The following
61.BR sysconf (3)
62calls make use of the functions documented on this page
63to return the same information.
64.PP
65.in +4n
66.EX
67np = sysconf(_SC_NPROCESSORS_CONF); /* processors configured */
68np = sysconf(_SC_NPROCESSORS_ONLN); /* processors available */
69.EE
70.in
71.SH EXAMPLES
72The following example shows how
73.BR get_nprocs ()
74and
75.BR get_nprocs_conf ()
76can be used.
77.PP
78.\" SRC BEGIN (get_nprocs_conf.c)
79.EX
80#include <stdio.h>
81#include <stdlib.h>
82#include <sys/sysinfo.h>
83
84int
85main(void)
86{
87 printf("This system has %d processors configured and "
88 "%d processors available.\en",
89 get_nprocs_conf(), get_nprocs());
90 exit(EXIT_SUCCESS);
91}
92.EE
93.\" SRC END
94.SH SEE ALSO
95.BR nproc (1)