Priority Scheduling

  • Priority scheduling assigns each process a priority, and the CPU is allocated to the highest-priority process.
  • Equal-priority processes are scheduled in FCFS order. SJF is a special case where priority is the inverse of next CPU burst.

Example

Consider the following set of processes with their burst times and priorities:

ProcessBurst TimePriority
P1103
P211
P324
P415
P552

Using priority scheduling, we would schedule these processes according to the following Gantt chart:

The average waiting time is calculated to be 8.2 milliseconds.

  • Priorities can be defined internally or externally.
    • Internally defined priorities use measurable quantities like time limits, memory requirements, or ratios of I/O burst to CPU burst.
    • External priorities are set by criteria outside the operating system, such as the importance of the process or political factors.
  • Priority scheduling can be preemptive or nonpreemptive.
    • In preemptive priority scheduling, a newly arrived process with a higher priority can preempt the CPU from the currently running process.
    • In nonpreemptive priority scheduling, the new process is simply placed at the head of the ready queue.

A major issue with priority scheduling algorithms is indefinite blocking or starvation, where low-priority processes wait indefinitely for CPU access. Aging is a solution to this problem, involving gradually increasing the priority of processes that wait in the system for a long time. This ensures that even low-priority processes eventually get CPU access.

Priority scheduling offers flexibility in process execution by allowing processes to be prioritized based on various criteria. However, care must be taken to prevent indefinite blocking of low-priority processes through techniques like aging.

Design a site like this with WordPress.com
Get started