Tag: detect cpu count

  • Detect number of CPUs on a machine

    UPDATE: Steven pointed out (very nicely) that there’s no need for cat in this picture, grep would do just fine on its own. So, thanks Steven!

    Detect how many CPU cores are present on the running machine:

    grep -c processor /proc/cpuinfo
    

    This can be very useful when writing multi-threaded programs to properly match the number of threads with the number of CPU cores.

    (more…)