SHTK_HW_CPUS(3)

πŸ“¦ version 1.7, in nixos 26.05, nixpkgs unstable

πŸ’» SHTK_HW_CPUS(3) πŸ’»

okay bestie, welcome to SHTK_HW_CPUS(3) β€” this one lives in the Library Functions Manual and it's here to help you count CPU threads like a total icon. πŸ’…


🌸 NAME 🌸

shtk_hw_ncpus β€” queries the number of CPUs (threads) in the machine. fr fr, that's the whole assignment. ✨


πŸŽ€ LIBRARY πŸŽ€

You pull this in with:

shtk_import hw

✨ SYNOPSIS ✨

shtk_hw_ncpus

πŸ’– DESCRIPTION πŸ’–

okay so shtk_hw_ncpus goes and asks the machine how many CPU threads it has, then prints the total number to stdout. lowkey useful, highkey slay. πŸ”₯

If the query fails, or if the function does not know how to get the number from the current operating system, it prints 1. no cap, that's the fallback. 🫢


πŸ”₯ RETURN VALUES πŸ”₯

shtk_hw_ncpus returns 0. periodt. πŸ‘‘


πŸ¦‹ EXAMPLES πŸ¦‹

bestie, here's the iconic make moment:

make -j"$(shtk_hw_ncpus)" all

🌈 ENVIRONMENT 🌈

  • SHTK_HW_NCPUS β€” if set to a number greater than zero, overrides the return value of shtk_hw_ncpus. Generally useful for testing purposes, but can also be useful to inject greater numbers of parallelism in applications that do not expose a mechanism to tune such number. πŸ’œ

πŸ‘‘ SEE ALSO πŸ‘‘

shtk(3), shtk_hw(3) πŸŽ€


🧚 HISTORY 🧚

shtk_hw_ncpus first appeared in shtk 1.7. iconic behavior, honestly. 🌟


mwah πŸ’‹ this lil page is from Debian, dated February 6, 2017, and its footer tag is SHTK_HW_CPUS(3). πŸ“

πŸ“¦ where this page comes from