5 OS SchedulingAlgorithms
5 OS SchedulingAlgorithms
Process Scheduling
Scheduling of processes/work is done to finish the work on time.
CPU Scheduling is a process that allows one process to use the
CPU while another process is delayed (in waiting state) due to
unavailability of any resources such as I / O etc, thus making full use
of the CPU.
The purpose of CPU Scheduling is to make the system more
efficient, faster, and fairer.
Whenever the CPU becomes idle, the operating system must select
one of the processes in the line ready for launch.
The selection process is done by a CPU scheduler.
The main function of the CPU scheduling is to ensure that whenever
the CPU remains idle, the OS has at least selected one of the
processes available in the ready-to-use line.
Terminologies for CPU Scheduling
Arrival Time: Time at which the process arrives in the ready
queue.
Completion Time: Time at which process completes its
execution.
Burst Time: Time required by a process for CPU execution.
Turn Around Time: Time Difference between completion time
and arrival time.
Turn Around Time = Completion Time – Arrival Time
Waiting Time(W.T): Time Difference between turn around time
and burst time
Waiting Time = Turn Around Time – Burst Time
Response Time: Response time is the time spent when the
process is in the ready state and gets the CPU for the first time
What are the different types of CPU
Scheduling Algorithms?
There are mainly two types of scheduling methods:
Preemptive Scheduling:
1. The resources (mainly CPU cycles) are allocated to the
process for a limited amount of time and then taken away,
and the process is again placed back in the ready queue if
that process still has CPU burst time remaining.
2. That process stays in the ready queue till it gets its next
chance to execute.
Scheduling Algorithms:
Round Robin (RR),
Shortest Remaining Time First (SRTF),
Priority (preemptive version), etc.
What are the different types of CPU
Scheduling Algorithms?
There are mainly two types of scheduling methods:
Non-Preemptive Scheduling:
1. In this scheduling, once the resources (CPU cycles) are
allocated to a process, the process holds the CPU till it gets
terminated or reaches a waiting state.
2. In the case of non-preemptive scheduling does not interrupt
a process running CPU in the middle of the execution.
3. Instead, it waits till the process completes its CPU burst
time, and then it can allocate the CPU to another process.
Scheduling Algorithms:
Shortest Job First (SJF basically non preemptive) and
Priority (non preemptive version), etc.
Preemptive vs Non- Preemptive
Scheduling
Preemptive Scheduling
Non-Preemptive Scheduling
Different types of CPU Scheduling
Algorithms
Priority Scheduling
Round-Robin
CPU Scheduling
Shortest Job First
First-Come First-Serve
Non-Preemptive
Longest Job First
Example:
Consider the following table of arrival time, Priority and burst time for
five processes P1, P2, P3, P4 and P5
Input :
Process_no arrival_time Burst_time priority
P1 0 3 2
P2 1 6 1
P3 2 1 3
P4 3 2 3
P5 4 4 2
Priority Process Schedulling Algorithm
Preemptive:
INPUT :
Process_no arrival_time Burst_time priority
P1 0 3 2
P2 1 6 1
P3 2 1 3
P4 3 2 3
P5 4 4 2
Gantt Chart:
0 1 7 9 13 14 16
P1 P2 P1 P5 P3 P4