Files
linux-kernel-module-cheat/userland/cpp/thread_hardware_concurrency.cpp
Ciro Santilli 六四事件 法轮功 e0fb39c92a userland: move more multithreading from cpp-cheat!
Convert infinite_loop.c into loop.c. Keep all examples fast by default!
2019-09-07 00:00:03 +00:00

13 lines
439 B
C++

// https://cirosantilli.com/linux-kernel-module-cheat#cpp-multithreading
//
// http://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine
//
// Not affected by taskset: https://stackoverflow.com/questions/1006289/how-to-find-out-the-number-of-cpus-using-python/55423170#55423170
#include <iostream>
#include <thread>
int main() {
std::cout << std::thread::hardware_concurrency() << std::endl;
}