CS 240 :OPERATING
SYSTEM
MODULE- 5
PROCESS SCHEDULING ALGORITHMS
Dr. Shailendra Mishra
College of Computer & Information Sciences
Majmaah University
Slide Title Introduction
Slide NO 01I
Introduction
Dear student, in
this Lesson we Process Scheduling, CPU Scheduling,
will be studying Scheduling Criteria, Scheduling
Algorithms and Algorithm Evaluation.
Scheduler selects a process among the
processes in memory that are ready to
execute, and allocates it to the CPU.
Scheduling decision will take place when
a process switches from running to
waiting state or it switches from running
to ready state or it switches from
waiting to ready.
Slide Title Process Scheduling.1
Slide NO 1
Representation of Process Scheduling
It selects a process among the processes in memory that are ready to execute, and allocates it to the CPU. Scheduling
decision will take place when a process switches from running to waiting state or it switches from running to ready state
.or it switches from waiting to ready
Long-term scheduler (or job scheduler) – Long-term scheduler selects which processes should be brought into the ready
queue
Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates to CPU
Addition of Medium Term Scheduling
Slide Title Basic Concepts in scheduling
Slide NO 2
Scheduling
Issues,
Implementatio Brust cycle
ns and
Mechanisms
Scheduling
Scheduler
Algorithms
Basic Concepts in
scheduling
Scheduling Preemptio
Criteria n
dispatcher
Slide Title Burst time
Slide NO 3
CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait. Process begins with
a CPU burst then waits for an I/O operation. When the I/O completes the process will run for a period of time
then wait again for another I/O operation. This cycle repeats ending with a final CPU burst which ends with
the process voluntarily terminating.
Slide Title CPU Scheduler is also known
Slide NO 4
Scheduling decisions occur when تغيير الجملة
process:
بالتزامن مع
[Link] from running to waiting state. التسجيل
Slide Title Scheduling Criteria .2
Slide NO 5
Processor Response
Utilization Time
Throughput Waiting Time
Turnaround
Time
Slide Title Optimization Criteria
Slide NO 6
1 Maximum CPU utilization
2 Maximum throughput
3 Minimum turnaround time
4 Minimum waiting time
5 Minimum response time
Slide Title Scheduling Algorithms .3
Slide NO 7
FIFO (or
FCFS)
Multilevel Shortest-
feedback Job-First
queue (SJF)
Scheduling
Algorithms
Multilevel Priority-
Queue based
Round-
robin
Slide Title FIFO ( First in First Out)
Slide NO 8
In this algorithm, Process’s
Control Blocks are placed on
FIFO Ready queue
Example 1
Slide Title Shortest-Job-First (SJF) Scheduling
Slide NO 9
1 non-preemptive
Example 2
2 Preemptive
Slide Title :Round Robin (RR) Scheduling
Slide NO 10
Round Robin (RR) Scheduling is similar to FCFS Example 3
but permit preemption
Slide Title Multilevel Queue Scheduling
Slide NO 11
Multi-level queue scheduling algorithm processes are Example 4
grouped as ;
Slide Title Assignment No 3 (a)
Slide NO 01H
: Dear student, you should be do this
1. Explain the difference between preemptive and non-preemptive scheduling.
2. A CPU-scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be
scheduled on one processor, how many different schedules are possible? Give a formula in terms of n.
3. Explain the criteria to be considered in case of CPU scheduling Four Process P1 to P4 in given diagram , Apply FIFO and SJF
and RR algorithm ,Draw GANTT Chart and Calculate Av. Waiting time, Average Turn Around Time, on the basis of above justify
which algorithm is better
Process Arrival Time Burst Time
P1 0 8
P2 1 6
P3 2 9
P4 3 10
4. Suppose that the following processes arrive for execution at the times indicated. Each process will
run for the amount of time listed. In answering the questions, use non-preemptive scheduling, and
base all decisions on the information you have at the time the decision must be made.
Process Arrival Time Burst Time
P1 0.0 8
P2 0.4 4
P3 1.0 1
?a. What is the average turnaround time for these processes with the FCFS scheduling algorithm
?b. What is the average turnaround time for these processes with the SJF scheduling algorithm
c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process
P1 at time 0 because we did not know that two shorter processes would arrive soon. Compute
what the
average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is
used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time
.may increase. This algorithm could be known as future-knowledge scheduling