Process Scheduling
in Operating Systems
V.V.SUBRAHMANYAM
SOCIS, IGNOU
DATE: 22-02-08
TIME: 17-00 TO 17-45
Functions of an Operating
System
Resource Manager
Process Scheduling
Memory Management
Virtual Memory Management
Deadlock Handling
File Management
I/O Management
Protection & Security
Process Scheduling

Scheduling is an activity of selecting the
next request to be serviced by a server.

The main objective of scheduling is to
increase CPU utilization and higher
throughput
Contd...

A schedule policy used in the operating
systems influences user service, efficient
use of resources and system performance.

Scheduling policies use the fundamental
techniques of preemption, reordering of
requests and variation of time slice to
achieve their goals.

Performance analysis of scheduling
policies is important for tuning the
performance of a scheduling policy.
Scheduling Objectives

Maximize throughput

Maximize the number of interactive user
receiving acceptable response times.

Be predictable

Minimize overhead

Balance resource use
Contd...

Achieve a balance between response and
utilization

Avoid indefinite postponement

Enforce priorities

Give preference to the processes holding the key
resources

Degrade gracefully under heavy loads
Schedulers
An OS has to adapt its functioning to the
availability of resources in the system: it
uses a combination of three schedulers
called long-term, medium-term and short-
term schedulers for this purpose.
Features of Schedulers
 Long term
scheduling
Decides when to admit
an arrived process for
scheduling based on
its nature, whether
CPU bound or I/O
bound, and availability
of resources like kernel
data structures, user
terminals and disk
space for swapping.
Contd...
 Medium Term
scheduling
Moves processes
between the
memory and the
disk to optimize use
of the memory.
Maintains a
sufficient number of
ready processes in
the memory.
Contd...

Short term
scheduling
 Decides which
ready process to
execute next and
for how long.
Scheduling-related concepts and
terms
CPU Utilization: The key idea is that if the CPU
is busy all the time, the utilization factor of all the
components of the system will be also high. CPU
utilization is the ratio of busy time of the
processor to the total time passes for processes
to finish.
Processor Utilization =
(Processor busy time) / (Processor busy time +
Processor idle time)
Contd...
Throughput: It refers to the amount of
work completed in a unit of time. One way
to measure throughput is by means of the
number of processes that are completed in
a unit of time.
Throughput = (No. of processes completed) /
(Time unit)
Contd...
Turnaround Time : It may be defined as
interval from the time of submission of a
process to the time of its completion.
Turnaround Time =
t(Process completed) – t(Process Submitted)
Contd..
Waiting Time: This is the time spent in the
ready queue.
Waiting time = Turn around Time - Processing
Time
Contd...
Response Time: Time between the
submission of a request for processing to
the time its result becomes available.
Response time =
t(first response) – t(submission of request)
Types of Scheduling Policies
A major division among scheduling
algorithms is that whether they support
pre-emptive or non-preemptive
scheduling discipline.
Non Preemptive Scheduling

In non-preemptive scheduling, a server
always processes a scheduled request to
completion.

Next processes scheduling is performed
only when processing of the previously
scheduled request gets completed.

It is attractive due to its simplicity.

Since preemption is not used, the
scheduler depends on reordering of
requests to achieve an improvement in user
service or system performance.
Non-preemptive Scheduling
policies

FCFS Scheduling

Shortest Request next(SRN) scheduling

Highest Response Ratio Next(HRN)
scheduling
Preemptive Scheduling Policies
In preemptive scheduling, the server can be
switched to the processing of a new request
before completing the current request. The
preempted request is put back into the list of
pending requests. Its servicing will be
resumed when it is scheduled again.
Shortest Request Next
Scheduling
 The SRN scheduler always schedules the
shortest of the arrived requests. Thus, a
request remains pending until all shorter
requests have been serviced.
Highest Response Ratio
 The HRN policy computes the response
ratios of all the processes in the system
according to the following equation and
selects the process with the highest
response ration.
Response Ratio =
(Arrival Time + Service time)/Service Time
Example
 Process P1 P2 P3 P4 P5
 Arrival Time 0 2 3 5 9
 Service Time 3 3 2 5 3
Contd...
 FCFS Scheduling : P1, P2, P3, P4, P5
 SRN Scheduling : P1, P3, P2, P4, P5
 HRN Policy : P1, P2, P4, P5, P3
Preemptive Scheduling Policies

Round Robin with time slicing

Least Completed Next (LCN) scheduling

Shortest time to go (STG) scheduling

Highest Response-Ratio Next (HRN)
scheduling
Round Robin Scheduling
 Round Robin Scheduling with time slicing is
aimed at providing fair service to all the
requests. Time slicing is used to limit the
amount of CPU time a process may use
when scheduled. A request is preempted if
the time slice elapses.
Least Completed Next
 The LCN policy schedules the process that
has consumed the least amount of CPU
time.
Shortest time to go (STG)
 The STG policy is a preemptive version of
the SRN policy. A process is scheduled
when its remaining processing
requirements are the smallest in the
system. It favors a process that is nearing
completion irrespective of the CPU time
already consumed by it.
Example
 Process P1 P2 P3 P4 P5
 Arrival Time 0 2 3 5 9
 Service Time 3 3 2 5 3
Contd...
 Round Robin
P1, P1, P2, P1, P3, P2, P4, P3, P2, P4, P5,
P4, P5, P4, P5, P4
 LCN
P1, P1, P2, P3, P2, P4, P3, P4, P1, P5, P5,
P2, P4, P5, P4, P4
 STG
P1, P1, P1, P3, P3, P2, P2, P2, P4, P5, P5,
P5, P4, P4, P4, P4
Priority Based Scheduling
 Priority is a tie-breaking rule that is
employed by a scheduler when many
requests await attention of the server.
 Priority based scheduling has the drawback
that a low priority request may never be
serviced if high priority requests keep
arriving. This situation is called as
starvation.
Contd..
 It could be avoided by incrementing the
priority of a request if it does not get
scheduled for a certain period of time.
Thus, the priority of a low priority request
would keep increasing as it waits to get
scheduled until its priority exceeds the
priority of all other pending requests. At this
time, it would get scheduled. This
technique is called as aging of requests.
Thank You

Process Scheduling

  • 1.
    Process Scheduling in OperatingSystems V.V.SUBRAHMANYAM SOCIS, IGNOU DATE: 22-02-08 TIME: 17-00 TO 17-45
  • 2.
    Functions of anOperating System Resource Manager Process Scheduling Memory Management Virtual Memory Management Deadlock Handling File Management I/O Management Protection & Security
  • 3.
    Process Scheduling  Scheduling isan activity of selecting the next request to be serviced by a server.  The main objective of scheduling is to increase CPU utilization and higher throughput
  • 4.
    Contd...  A schedule policyused in the operating systems influences user service, efficient use of resources and system performance.  Scheduling policies use the fundamental techniques of preemption, reordering of requests and variation of time slice to achieve their goals.  Performance analysis of scheduling policies is important for tuning the performance of a scheduling policy.
  • 5.
    Scheduling Objectives  Maximize throughput  Maximizethe number of interactive user receiving acceptable response times.  Be predictable  Minimize overhead  Balance resource use
  • 6.
    Contd...  Achieve a balancebetween response and utilization  Avoid indefinite postponement  Enforce priorities  Give preference to the processes holding the key resources  Degrade gracefully under heavy loads
  • 7.
    Schedulers An OS hasto adapt its functioning to the availability of resources in the system: it uses a combination of three schedulers called long-term, medium-term and short- term schedulers for this purpose.
  • 8.
    Features of Schedulers Long term scheduling Decides when to admit an arrived process for scheduling based on its nature, whether CPU bound or I/O bound, and availability of resources like kernel data structures, user terminals and disk space for swapping.
  • 9.
    Contd...  Medium Term scheduling Movesprocesses between the memory and the disk to optimize use of the memory. Maintains a sufficient number of ready processes in the memory.
  • 10.
    Contd...  Short term scheduling  Decideswhich ready process to execute next and for how long.
  • 11.
    Scheduling-related concepts and terms CPUUtilization: The key idea is that if the CPU is busy all the time, the utilization factor of all the components of the system will be also high. CPU utilization is the ratio of busy time of the processor to the total time passes for processes to finish. Processor Utilization = (Processor busy time) / (Processor busy time + Processor idle time)
  • 12.
    Contd... Throughput: It refersto the amount of work completed in a unit of time. One way to measure throughput is by means of the number of processes that are completed in a unit of time. Throughput = (No. of processes completed) / (Time unit)
  • 13.
    Contd... Turnaround Time :It may be defined as interval from the time of submission of a process to the time of its completion. Turnaround Time = t(Process completed) – t(Process Submitted)
  • 14.
    Contd.. Waiting Time: Thisis the time spent in the ready queue. Waiting time = Turn around Time - Processing Time
  • 15.
    Contd... Response Time: Timebetween the submission of a request for processing to the time its result becomes available. Response time = t(first response) – t(submission of request)
  • 16.
    Types of SchedulingPolicies A major division among scheduling algorithms is that whether they support pre-emptive or non-preemptive scheduling discipline.
  • 17.
    Non Preemptive Scheduling  Innon-preemptive scheduling, a server always processes a scheduled request to completion.  Next processes scheduling is performed only when processing of the previously scheduled request gets completed.  It is attractive due to its simplicity.  Since preemption is not used, the scheduler depends on reordering of requests to achieve an improvement in user service or system performance.
  • 18.
    Non-preemptive Scheduling policies  FCFS Scheduling  ShortestRequest next(SRN) scheduling  Highest Response Ratio Next(HRN) scheduling
  • 19.
    Preemptive Scheduling Policies Inpreemptive scheduling, the server can be switched to the processing of a new request before completing the current request. The preempted request is put back into the list of pending requests. Its servicing will be resumed when it is scheduled again.
  • 20.
    Shortest Request Next Scheduling The SRN scheduler always schedules the shortest of the arrived requests. Thus, a request remains pending until all shorter requests have been serviced.
  • 21.
    Highest Response Ratio The HRN policy computes the response ratios of all the processes in the system according to the following equation and selects the process with the highest response ration. Response Ratio = (Arrival Time + Service time)/Service Time
  • 22.
    Example  Process P1P2 P3 P4 P5  Arrival Time 0 2 3 5 9  Service Time 3 3 2 5 3
  • 23.
    Contd...  FCFS Scheduling: P1, P2, P3, P4, P5  SRN Scheduling : P1, P3, P2, P4, P5  HRN Policy : P1, P2, P4, P5, P3
  • 24.
    Preemptive Scheduling Policies  RoundRobin with time slicing  Least Completed Next (LCN) scheduling  Shortest time to go (STG) scheduling  Highest Response-Ratio Next (HRN) scheduling
  • 25.
    Round Robin Scheduling Round Robin Scheduling with time slicing is aimed at providing fair service to all the requests. Time slicing is used to limit the amount of CPU time a process may use when scheduled. A request is preempted if the time slice elapses.
  • 26.
    Least Completed Next The LCN policy schedules the process that has consumed the least amount of CPU time.
  • 27.
    Shortest time togo (STG)  The STG policy is a preemptive version of the SRN policy. A process is scheduled when its remaining processing requirements are the smallest in the system. It favors a process that is nearing completion irrespective of the CPU time already consumed by it.
  • 28.
    Example  Process P1P2 P3 P4 P5  Arrival Time 0 2 3 5 9  Service Time 3 3 2 5 3
  • 29.
    Contd...  Round Robin P1,P1, P2, P1, P3, P2, P4, P3, P2, P4, P5, P4, P5, P4, P5, P4  LCN P1, P1, P2, P3, P2, P4, P3, P4, P1, P5, P5, P2, P4, P5, P4, P4  STG P1, P1, P1, P3, P3, P2, P2, P2, P4, P5, P5, P5, P4, P4, P4, P4
  • 30.
    Priority Based Scheduling Priority is a tie-breaking rule that is employed by a scheduler when many requests await attention of the server.  Priority based scheduling has the drawback that a low priority request may never be serviced if high priority requests keep arriving. This situation is called as starvation.
  • 31.
    Contd..  It couldbe avoided by incrementing the priority of a request if it does not get scheduled for a certain period of time. Thus, the priority of a low priority request would keep increasing as it waits to get scheduled until its priority exceeds the priority of all other pending requests. At this time, it would get scheduled. This technique is called as aging of requests.
  • 32.