- Code: Select all
int cpu_count() {
return Min(sysconf(_SC_NPROCESSORS_ONLN), 8);
}
This seems to work fine, but I also need a similar function for Windows. After some Googling, I came up with the following function, but because I don't have any Windows computers, I can't test if it works. Does the following look correct?
- Code: Select all
int cpu_count() {
SYSTEM_INFO s;
GetSystemInfo(&s);
return Min(s.dwNumberOfProcessors, 8);
}
The Min(<whatever>, 8) thing in the code is there simply because my program is currently limited to a maximum of 8 threads.
Tord