Operating System - CPU Scheduling

<<Previous

Next >>




We are going to learn about CPU scheduling, about the CPU Burst, IO Burst and the CPU IO Burst cycle. We are also going to learn about the Preemptive and Non-preemptive Scheduling, how the Dispatcher does the work and about Dispatch Latency

Basic Concept

In multi-programming, there are more than one process present in the memory at a time. When running process has to wait, the operating system removes the CPU time allocated to it and assigns the time to the another process. The process of allocating CPU time from one running process to another process is called CPU Scheduling.

CPU-I/O Burst Cycle

CPU Burst

It is the amount of time, a process uses the CPU until it starts waiting for some input or interrupted by some other process

I/O Burst or Input Output burst

It is the amount of time, a process waits for input-output before needing CPU time.

Burst Cycle

The execution of process consists of a cycle of CPU burst and I/O burst. Usually it starts with CPU burst and then followed by I/O burst, another CPU burst, another I/O burst and so on. This cycle will continue until the process is terminated.

CPU bound and I/O bound

In Actual, a Process comprises of CPU bound and I/O bound programs. An I/O bound program has many short CPU bursts. A CPU bound program might have a few long CPU bursts.

CPU Scheduler

When the running process has to wait, the operating system must select a different process and then allocate the processor time to it. This selection is done by the short-term scheduler or CPU scheduler which selects the process from ready queue.

Preemptive scheduling

In Preemptive scheduling, whenever the high priority process wants to execute, then the running low priority process can be preempted and processor is assigned to that high priority process. Preemptive scheduling occurs:

  • When the process switches from running to ready state due to an interruption.
  • When the process switches from waiting to ready state after completion of I/O request.

Non-preemptive scheduling

Once the process is allotted with CPU, it keeps the CPU time until it completes its task or moves to the waiting state. NonPreemptive scheduling occurs:

  • When the process switches from running to waiting state for I/O request.
  • When a process terminates.

Dispatcher & Dispatch latency

Dispatcher is the module which gives the control of CPU to the process that has been selected by the short-term scheduler. Dispatch latency is defined as the time taken by the dispatcher to stop one process and start running the another process.


<<Previous

Next >>