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.
Asked
Active
Viewed 1,209 times
1

Claudiu
- 205
1 Answers
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
LD_PRELOAD
orptrace
. I don't know if there's a ready-made solution. – Gilles 'SO- stop being evil' Jan 26 '15 at 20:47