I'm trying to give an CPU-bound application the lowest scheduling priority with renice 19
(Linux 3.11). However, it doesn't seem to work as expected or I have an understanding problem.
Let me describe two ways how I've tried it. I expected that in both ways I'd get the same results, but I don't. Consider the application loop
to be a busy loop: int main() { for(;;) ; return 0; }
.
Experiment 1
- opened a terminal
- ran
./loop &
as many times as CPUs (eg, I have 4 CPUs). - ran a further instance of
loop
and reniced it to 19
Result was as expected. The non-reniced loop
instances have almost 100% CPU each, and the reniced instance has about 1%.
Experiment 2
- opened two terminals
- Terminal 1: ran
./loop &
as many times as CPUs. - Terminal 2: ran a further instance of
loop
and renice it to 19
Result was not as expected. The loop
instance started in Terminal 2 had 100% (although with niceness 19), whereas the loop
instances in Terminal 1 shared the rest of the resources.
Question
Why does not experiment 2 behave as experiment 1?