Kernel Representation of Priorities

The static priority of a process can be set in userspace by means of the nice command, which internally invokes the nice system call.25 The nice value of a process is between -20 and +19 (inclusive). Lower values mean higher priorities. Why this strange range was chosen is shrouded in history.

The kernel uses a simpler scale ranging from 0 to 139 inclusive to represent priorities internally. Again, lower values mean higher priorities. The range from 0 to 99 is reserved for real-time processes. The nice values [-20, +19] are mapped to the range from 100 to 139, as shown in Figure 2-14. Real-time processes thus always have a higher priority than normal processes can ever have.

25setpriority is an alternative system call for setting process priority. It is able to modify not only the priority of an individual thread but also the priorities of all threads in a thread group or of all processes of a specific user, selected by means of the UID.

Higher Priority




Continue reading here: Computing Priorities

Was this article helpful?

0 0