I recently managed to make a bit of a mess of things while doing some multi-process programming using fork(). While the box was still semi-usable I was unable to kill off the processes faster than they were being created and I ended up resorting to a reboot.
At the time I wasn't entirely sure what the problem was and not cherishing the prospect of more reboots I used taskset to constrain my shell, its child processes including test runs of my program and of course its forked children to a single CPU.
# taskset -p 01 $$
The result? A subsequent fork explosion was indeed constrained to one CPU and I was able to kill off all the processes quite easily.
My system is a single socket with four cores. I have disabled hyper-threading
so there is only one thread per core. I am unsure how well this technique
would work in other situations, especially in the case of multiple threads
but only one socket and one core.
Thu, 10 Mar 2011 11:01:08 +0900| Permalink