Is there any way I can trick a program into thinking the system has fewer processors? To explain: I am debugging a program that creates as many threads as it has processors, using sysconf(_SC_NPROCESSORS_CONF);. I'd like to test it using only one threat. Strictly for convenience, I'd like to know if there's a way I can trick the program into thinking the computer only has one processor, to avoid having to add a command line option or changing the code to temporarily only create one thread.


Under FreeBSD (>=7.1), you can use the /usr/bin/cpuset command eg :

# cpuset -l 0,2 -c -p <pid>

Under Linux, see : http://man7.org/linux/man-pages/man7/cpuset.7.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.