Scheduling
Unix Scheduling Allocating CPU to a Process The amount of time that a process is allocated the CPU is called a time quantum Processes are assigned a priority CPU is allocated based on the priority of the process
Process Scheduling Unix uses the round robin with multilevel feedback In short, CPU is allocated to a process for a time quantum, when the time quantum is exceeded, the process is preempted and is added to one of several priority queues.
RRMF quantum = 24 CPU
Scheduling Algorithm
Scheduling Parameters Priority Field Two ranges for priorities –User priorities –Kernel priorities High Low
Range of Priorities Ranges of process priorities –0 thru 127 (system dependent) –Threshold Priority (50) PUSER 50 – user mode execution –Priorities less then 50 are general kernel level processes PSWP 0 - kernel mode while swapping
Priority Ranges 0 50
Priorities Some Priorities are hard coded –Process that about to go to sleep receive a priority based on reason for sleeping Some are calculated –Decay function CPU ~ CPU/2 –Priority ~ (recent CPU usage/2) + base priority
When Are Priorities Changed When a process is about to sleep Process returning from kernel mode to user mode After the CPU usage is recalculated (caused by the clock)
Priority Example 3 process –Initial priority 60 –Clock interrupts 60 times a second –No syscalls –No other processes are ready to run
Priority Example
Priority Example 2
User Influence on Priorities Users can have a nominal impact on the priority assigned to their process Nice systcall –nice(value) –Where value is added to the priority calculation –P = (recent CPU usage/2) +(base P) + nice
Fair Share Scheduling Similar in concept to RRML, but allows block of time to be allocated to a set or groups of processes Divide user community into set of fare share groups
Fair Share Scheduling Processes within a group are subject to the same scheduling and priority constraints Each group or set of processes are allocated a portion of the CPU