In priority scheduling, processes are assigned priorities. The CPU is allocated to the process with the highest priority first.
Which statement best describes what happens if two processes have the same priority?
Think about how operating systems handle ties in priority.
When two processes have the same priority, the scheduler usually uses the arrival time to decide which process runs first, following a first-come, first-served approach.
Which of the following correctly distinguishes preemptive priority scheduling from non-preemptive priority scheduling?
Consider what happens when a higher priority process arrives while another is running.
Preemptive priority scheduling allows interruption of the running process if a higher priority process arrives. Non-preemptive scheduling waits for the running process to finish before switching.
Given three processes with arrival times and priorities:
- P1: arrival=0, burst=4, priority=2
- P2: arrival=1, burst=3, priority=1
- P3: arrival=2, burst=1, priority=3
Using preemptive priority scheduling (lower number means higher priority), what is the average waiting time?
Simulate the process execution timeline considering preemption by higher priority processes.
Execution timeline:
- 0-1: P1 (1 unit)
- 1-4: P2 (3 units, preempts P1 due to higher priority)
- 4-7: P1 resumes (remaining 3 units)
- 7-8: P3 (1 unit)
Waiting times:
- P1: 3 units (waits 1-4)
- P2: 0 units
- P3: 5 units (waits 2-7)
Average waiting time = (3 + 0 + 5) / 3 = 8/3 ≈ 2.67 units.
What is the main purpose of aging in priority scheduling?
Think about how aging helps processes that wait too long.
Aging gradually increases the priority of processes that wait in the queue to ensure they eventually get CPU time, preventing starvation.
Consider a priority scheduling system where priorities range from 1 (highest) to 5 (lowest). If a low priority process arrives and there is a continuous stream of higher priority processes, what will happen to the low priority process?
Consider what happens when higher priority processes keep arriving.
In priority scheduling without aging, low priority processes can be starved if higher priority processes keep arriving, preventing them from running.