Facebook Pixel

Process Scheduling in Operating Systems

Process scheduling in an operating system refers to the technique used to decide which process gets access to the CPU and when. Since multiple processes may compete for CPU time, the OS must manage them efficiently.

Main Objectives
The primary goals of scheduling are to ensure fair CPU allocation among processes, maximize CPU utilization, and maintain overall system performance and responsiveness.

Types of Process Schedulers

Operating systems mainly use three types of schedulers to manage process execution and memory efficiently.

Long Term Scheduler (Job Scheduler)

Long Term Scheduler

Picks processes from the job pool and loads them into memory

The long term scheduler is responsible for selecting processes from the job pool (stored on disk) and loading them into the main memory (RAM). Once loaded, these processes move into the ready state.

  • Multiprogramming: Controls how many processes are present in memory at a time (degree of multiprogramming).
  • Selection Criteria: Selects processes based on factors like priority, resource needs, or execution time.
  • Frequency: Invoked less frequently (every few seconds or minutes).
  • Speed: Slowest scheduler because it involves heavy disk operations.
Example
If there are 10 processes waiting on disk and only 5 can fit in memory, the scheduler will pick 5 and load them, leaving the rest in the job pool.

Short Term Scheduler (CPU Scheduler)

Short Term Scheduler

Selects a process from the ready queue for CPU execution

The short term scheduler chooses a process from the ready queue and assigns it to the CPU for execution.

  • Algorithms: Works with scheduling algorithms like FCFS, SJF, and Round Robin.
  • Frequency: Runs very frequently (every few milliseconds).
  • Speed: Fastest scheduler because decisions must be made extremely quickly.
  • Dispatcher: Uses a dispatcher to physically switch the CPU between processes (saving state, loading state, transferring control). The time taken for this switch is called dispatch latency.
Example
If processes P1, P2, and P3 are in the ready queue and Round Robin is used, each process gets CPU time in turns based on a fixed time slice.

Medium Term Scheduler (Swapper)

Medium Term Scheduler

Manages memory by swapping processes in and out of RAM

The medium term scheduler manages memory by temporarily removing processes from RAM and storing them on disk. This process is called swapping.

  • Memory Load: Reduces memory load by suspending some processes.
  • Performance: Helps improve overall system performance during heavy load.
  • Frequency: Invoked occasionally when memory is limited.
  • Speed: Speed is between long term and short term schedulers.
Example
If memory is full and a new high-priority process needs space, the scheduler may move an existing process to disk and load the new one.

Comparison of Schedulers

FeatureLong TermShort TermMedium Term
Also CalledJob SchedulerCPU SchedulerSwapper
Main RoleLoads processes into memoryAssigns CPU to processesSwaps processes in/out
FrequencyRareVery frequentOccasional
SpeedSlowestFastestModerate
PurposeControls multiprogrammingManages ready queueReduces memory usage
Conclusion
The long term scheduler decides which processes enter memory, the short term scheduler decides which process runs on the CPU, and the medium term scheduler manages memory by swapping processes.

Flashcard

Which scheduler is responsible for controlling the degree of multiprogramming in an operating system?

Tap to flip
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.