# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

#### 24.3.1. Number of cores

    ./run --arch arm --cpus 2 --emulator gem5

Can be checked with `/proc/cpuinfo` or getconf in Ubuntu 18.04:

    cat /proc/cpuinfo
    getconf _NPROCESSORS_CONF

Or from User mode simulation, we can use either of:

- sysconf with userland/linux/sysconf.c

      ./run --cpus 2 --emulator gem5 --userland userland/linux/sysconf.c | grep _SC_NPROCESSORS_ONLN

- C++ multithreading's userland/cpp/thread_hardware_concurrency.cpp:

      ./run --cpus 2 --emulator gem5 --userland userland/cpp/thread_hardware_concurrency.cpp

- direct access to several special filesystem files that contain this information e.g. via userland/c/cat.c:

      ./run --cpus 2 --emulator gem5 --userland userland/c/cat.c --cli-args /proc/cpuinfo

- QEMU user mode multithreading

- gem5 ARM full system with more than 8 cores