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