get_nprocs(3)
π get_nprocs(3) β get number of processors π
okay bestie, listen. this is a page from the Library Functions Manual for get_nprocs, get_nprocs_conf, and it's genuinely so useful it's giving main character energy. sit down, grab a strawberry, we're counting CPUs. πβ¨
πΈ NAME πΈ
get_nprocs, get_nprocs_conf β get number of processors
π LIBRARY π
Standard C library (libc, -lc)
like, the standard one. the icon. π
β¨ SYNOPSIS β¨
#include <sys/sysinfo.h>
int get_nprocs(void);
int get_nprocs_conf(void);
two little functions, zero arguments, no cap. π«Ά
π¦ DESCRIPTION π¦
so get_nprocs_conf() returns the number of processors configured by the operating system. that's the how many exist in theory number.
and get_nprocs() returns the number of processors currently available in the system. that's the how many are actually showing up to the group chat right now number.
and here's the tea: this may be less than the number returned by get_nprocs_conf() because processors may be offline (e.g., on hotpluggable systems). so like, configured β currently awake. one of them is napping. π΄
π₯ RETURN VALUE π₯
As given in DESCRIPTION. literally just read the section above, bestie, it's right there.
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
- Interface:
get_nprocs(),get_nprocs_conf() - Attribute: Thread safety
- Value: MT-Safe
MT-Safe!! she's safe in threads, she can be called from anywhere, she's booked and busy and unbothered. π
π STANDARDS π
GNU.
that's it. that's the whole section. GNU only, deal with it. π
π NOTES π
the current implementation of these functions is rather expensive, since they open and parse files in the /sys filesystem each time they are called. like bestie... every single call?? every call. she's re-reading the same files over and over. obsessed with the drama of it but also, lowkey expensive. π
fr fr if you're calling this in a hot loop, maybe don't. the manpage is literally telling you it's costly. iykyk.
also!! the following sysconf(3) calls make use of the functions documented on this page to return the same information:
np = sysconf(_SC_NPROCESSORS_CONF); /* processors configured */
np = sysconf(_SC_NPROCESSORS_ONLN); /* processors available */
same info, different doorway. pick your fave. πͺβ¨
π§ EXAMPLES π§
the following example shows how get_nprocs() and get_nprocs_conf() can be used.
#include <stdio.h>
#include <stdlib.h>
#include <sys/sysinfo.h>
int
main(void)
{
printf("This system has %d processors configured and "
"%d processors available.\n",
get_nprocs_conf(), get_nprocs());
exit(EXIT_SUCCESS);
}
not me writing a whole C program just to flex how many cores my laptop has π iconic behaviour honestly. it prints both numbers and exits clean with EXIT_SUCCESS. periodt.
π SEE ALSO π
and that's the tea bestie π«Ά slay, go count some processors, and remember: configured β available. π
this was brought to you by Linux man-pages 6.20, dated 2026-02-08 β get_nprocs(3), out. πβ¨π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2012, Petr Benas
- Copyright 2012, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms