PROCESS PRIORITIES
AND SCHEDULING
This chapter discusses various system calls and process attributes that determine
when and which processes obtain access to the CPU(s). We begin by describing the
nice value, a process characteristic that influences the amount of CPU time that a
process is allocated by the kernel scheduler. We follow this with a description of the
POSIX realtime scheduling API. This API allows us to define the policy and priority
used for scheduling processes, giving us much tighter control over how processes
are allocated to the CPU. We conclude with a discussion of the system calls for set-
ting a process’s CPU affinity mask, which determines the set of CPUs on which a
process running on a multiprocessor system will run.
35.1 Process Priorities (Nice Values)
On Linux, as with most other UNIX implementations, the default model for sched-
uling processes for use of the CPU is round-robin time-sharing. Under this model,
each process in turn is permitted to use the CPU for a brief period of time, known
as a time slice or quantum. Round-robin time-sharing satisfies two important require-
ments of an interactive multitasking system:
z Fairness: Each process gets a share of the CPU.
z Responsiveness: A process doesn’t need to wait for long periods before it
receives use of the CPU.