1GET_NPROCS(3)              Linux Programmer's Manual             GET_NPROCS(3)
2
3
4

NAME

6       get_nprocs, get_nprocs_conf - get number of processors
7

SYNOPSIS

9       #include <sys/sysinfo.h>
10
11       int get_nprocs(void);
12       int get_nprocs_conf(void);
13

DESCRIPTION

15       The function get_nprocs_conf() returns the number of processors config‐
16       ured by the operating system.
17
18       The function get_nprocs() returns the number  of  processors  currently
19       available  in the system.  This may be less than the number returned by
20       get_nprocs_conf() because processors may be offline (e.g., on  hotplug‐
21       gable systems).
22

RETURN VALUE

24       As given in DESCRIPTION.
25

CONFORMING TO

27       These functions are GNU extensions.
28

NOTES

30       The  current  implementation  of  these  functions is rather expensive,
31       since they open and parse files in the /sys file system each time  they
32       are called.
33
34       The  following sysconf(3) calls make use of the functions documented on
35       this page to return the same information.
36
37           np = sysconf(_SC_NPROCESSORS_CONF);     /* processors configured */
38           np = sysconf(_SC_NPROCESSORS_ONLN);     /* processors available */
39

EXAMPLE

41       The following example shows how get_nprocs() and get_nprocs_conf()  can
42       be used.
43
44       #include <stdio.h>
45       #include <sys/sysinfo.h>
46
47       int
48       main(int argc, char *argv[])
49       {
50           printf("This system has %d processors configured and "
51                   "%d processors available.\n",
52                   get_nprocs_conf(), get_nprocs());
53           return 0;
54       }
55
56

COLOPHON

58       This  page  is  part of release 3.53 of the Linux man-pages project.  A
59       description of the project, and information about reporting  bugs,  can
60       be found at http://www.kernel.org/doc/man-pages/.
61
62
63
64GNU                               2012-03-20                     GET_NPROCS(3)
Impressum