/cpucount

Sample project that shows how to count CPU cores by building a shared library

Primary LanguageCGNU General Public License v3.0GPL-3.0

How to count CPU cores

I built this sample project to satisfy my curiosity: "How to count CPU cores by building and using a shared library in GNU/Linux?"

My curiosity was triggered by a few things:

First I became curious about the origin of "84" in cl-cpus-linux.lisp. Then I also wanted to see how I can build and consume a shared library but by using GCC on Linux (the Common Lisp Cookbook example uses Clang on Mac OS X). Finally, I also wanted to learn a bit more about sysconf, and getconf.

How to build

Please clone this git repository to your computer and then run make, e.g.:

$ git clone https://github.com/emres/cpucount
$ cd cpucount
$ make

After that you can run the resulting program:

$ ./call_cpucount_lib

Dependencies

This software has been tested on an Ubuntu GNU/Linux 17.10 and Fedora Linux 28, using GCC 7.2.0 (or higher), and GNU Make 4.1 (or higher). There are no other dependencies.