2 .\" Copyright (c) 2012, Petr Benas
3 .\" and Copyright (c) 2012, Michael Kerrisk <mtk.man-pages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH get_nprocs 3 (date) "Linux man-pages (unreleased)"
9 get_nprocs, get_nprocs_conf \- get number of processors
12 .RI ( libc ", " \-lc )
15 .B #include <sys/sysinfo.h>
17 .B int get_nprocs(void);
18 .B int get_nprocs_conf(void);
22 .BR get_nprocs_conf ()
23 returns the number of processors configured by the operating system.
27 returns the number of processors currently available in the system.
28 This may be less than the number returned by
29 .BR get_nprocs_conf ()
30 because processors may be offline (e.g., on hotpluggable systems).
32 As given in DESCRIPTION.
34 For an explanation of the terms used in this section, see
42 Interface Attribute Value
45 .BR get_nprocs_conf ()
46 T} Thread safety MT-Safe
52 These functions are GNU extensions.
56 implementation of these functions is rather expensive,
57 since they open and parse files in the
59 filesystem each time they are called.
63 calls make use of the functions documented on this page
64 to return the same information.
68 np = sysconf(_SC_NPROCESSORS_CONF); /* processors configured */
69 np = sysconf(_SC_NPROCESSORS_ONLN); /* processors available */
73 The following example shows how
76 .BR get_nprocs_conf ()
79 .\" SRC BEGIN (get_nprocs_conf.c)
83 #include <sys/sysinfo.h>
88 printf("This system has %d processors configured and "
89 "%d processors available.\en",
90 get_nprocs_conf(), get_nprocs());