1

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.

Claudiu
  • 205

1 Answers1

1

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