Weighting (Niceness)
Explore how the niceness level adjusts a process's priority in the Completely Fair Scheduler. Learn to calculate process weights and time slices, and understand how these affect CPU allocation and virtual runtime dynamics.
We'll cover the following...
Nice level of a process
CFS also enables controls over process priority, enabling users or administrators to give some processes a higher share of the CPU. It does this not with tickets, but through a classic UNIX mechanism known as the nice level of a process. The nice parameter can be set anywhere from -20 to +19 for a process, with a default of 0. Positive nice values imply lower priority and negative values imply higher priority; when you’re too nice, you just don’t get as much (scheduling) attention, alas.
CFS maps the nice value of each process to a weight, as shown here:
These weights allow us to compute the effective time slice of each process (as we did before), but now accounting for their priority differences. The formula used to do so is as follows:
= ...