DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Tuning CPU resources

Calculation of process priorities

A process' priority can range between 0 (lowest priority) and 127 (highest priority). User mode processes run at lower priorities (lower values) than system mode processes. A user mode process can have a priority of 0 to 65, whereas a system mode process has a priority of 66 to 95. Some of the system mode priorities indicate what a process is waiting for. For example, a priority of 81 indicates that a process is waiting for I/O to complete whereas a value of 75 means that it is waiting for keyboard input. The ps command with the -l option lists process priorities under the PRI column.

Processes with priorities in the range 96 to 127 have fixed priority and control their own scheduling.


NOTE: You can find a list of priority values in ``Priority values''.

``System process priorities'' shows the division of process priorities into user mode, system mode, and fixed-priority processes.

System process priorities

The operating system varies the priorities of executing processes according to a simple scheduling algorithm which ensures that each process on the system gets fair access to the CPU. Every process receives a base level priority (of default value 51) when it is created. However, this soon loses any influence on whether a process is selected to run. Note that the priorities of kernel daemons such as sched, vhand, and bdflush are not adjusted. Fixed-priority processes are also exempt -- such processes have the ability to adjust their own priority.

The kernel recalculates the priority of a running process every clock tick. The new priority is based on the process' nice value, and how much CPU time the process has used (if any). When the process is taken off the CPU, its lowered priority pushes it down the run queue to decrease the probability that it will be chosen to run in the near future.

A process that manages to run for an entire time slice will have had its priority reduced by the maximum amount.

The kernel recalculates the priorities of all runnable processes (those with a user mode priority less than 65) once every second by successively reducing the negative weighting given to their recent CPU usage. This increases the probability that these processes will be selected to run again in the near future.

The default nice value of a user's process is 20. An ordinary user can increase this value to 39 and in so doing reduce a process' chance of running on the CPU. Processes with low nice values will on average get more CPU time because of the effect the values have on the scheduling algorithm.

There are three ways to control the nice value of a process:


Next topic: Examining the run queue
Previous topic: Interrupts

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003