"Nice CPU" - How the nice value affects the per-process priority and usage

This short document shall give an idea how different "nice values" for different processes affect their percentual usage of the CPU as given by top.

In practice, it is simple. Just run two all-consuming processes, and nice one against the other. In my case, I had a setiathome running (nice 20) and a short CPU hogger which was re-niced from -20 throughout 20 while collecting the percentage values from top. The command was: perl -e 'while(1){}' &

These are the results (on a uniprocessor) of the tests done. Please note that they can not be precisely accurate. On the X axis, the nice value of perl is presented, whilst the Y axis shows the percentage it gained. The blue and green lines present the percentage when setiathome was scheduled at nice 20 and 0, respectively. (The red line is an assumption where Seti would be scheduled with nice -20.)

As seems logical, if two processes have the same nice value, they should get the same processor usage. This is reflected in the blue line at nice value 20 being at 50%. The overall curve is kind of decay-exponential. In the other run (green line), Seti ran with nice 0 and perl again from -20 to 20. I have not done another run with base at nice -20, but I guess it would be a mirrored version of base +20, shown in the thin red line.

Other experiments could include finding out the usage when there are three or even more processes running. Since I can predict the result based upon the above graph for two concurrent processes and the Kernel docs, I leave it up to you to play with it. (Only if you want to know.)