Priority Scheduling
Notes
- This is chapter 5.3.4
- The book says that Shortest Job First is an instance of priority scheduling.
- A scheduler, looking at the jobs, decides which have the highest priorities.
- There is no fixed scale for high and low
- Different OSs use different scales (0-7, 0 high, 1-4095, 4095 high)
- They use low numbers for high priority.
- This matches the unix/linux nice command
- Look at man page
- This allows a user to be "nice" and lower the priority of their process
- A range of -20 to 19
- The normal user can only increase their nice level
-
renice 20 pid
- The superuser can raise the priority level by assigning it a lower number.
- The book suggests a large number of ways to prioritize
- time used
- Resource requirements:
- Memory used
- Files open
- burst history
- But also external requirements set by users or admin
- renice or nice
- chrt (I don't know this well)
- Set, change or check a process' priority
- chrt -p pid
- (as root) chrt -r number pid
- Priorities between 1 (low) and 99 (high)
- YOu can also set the queue (or scheduler)
- Take a quick look
- We will be back.
- In a preemptive system, a process with a higher priority might interrupt the current process.
- The system needs to take starvation into account
- This can be countered with aging, or increasing a process' priority when it has not run
- Frequently round robin is used when there are multiple processes with the same priority.
- Current systems implement multiple queues
- This reduces the need to search all processes to schedule
- Simply select a process from the highest level non-empty queue.
- Real time, system, interactive, batch, idle
- Different scheduling algorithms can be applied to each of the queues
- To prevent starvation, systems can time-slice between queues
- Real Time needs to execute so it has priority
- The system level has 50% of the time
- The interactive has 30% of the time
- The batch queue has 20% of the time
- A queuing system, like interactive, might also have multiple queues
- When a process enters it is put into a "fast" queue, say quantum 8
- If it swaps out before the quantum expires it stays in that queue.
- If it exceeds that time, it moves the the quantum 16 queue
- This can be repeated until it reaches the FCFS with preemption queue
- look at
man 7 sched for a basic overview of linux scheduling
- EEVDF - Earliest Eligible Virtual Deadline First
- Designed for multicore systems
- Attempts to meet "virtual deadlines" based on how much time the process has used.
- And distribute time evenly by keeping track how how much time a process is "owed".
- This was added in 2024, based on a 1995 paper