Understand Process Management
• Process Scheduling Algorithms




                                               1
HOME     PREVIOUS TOPIC
NEXT
PREVIOUS QUESTION PAPERS
FOR OS
CPP TUTORIALS




                           2
Recap

In the last class, you have learnt

Shortest Job First scheduling algorithm and its

  -Advantages

  -Disadvantages




                                                  3
Objectives

On completion of this class, you would be able to know
• Priority Scheduling

• Round Robin Scheduling




                                                     4
Priority Scheduling

• Priority scheduling algorithm is special case of SJF

• A priority is associated with each process

• Priorities are indicated by fixed range of numbers

• In this scheduling CPU is allocated to the process with
  the highest priority
• Equal priority process scheduled in FCFS order


                                                         5
Priority Scheduling
• Consider the following set of processes assumed to have
  arrived at time 0,
   – in order P1,P2,P3-----P5
   – with the length of the CPU burst time given in milliseconds
   – and their associated priorities

               Process     Burst time Priorities
                 P1           10          3
                 P2            1          1
                 P3            2          4
                 P4            1          5
                 P5            5          2
                                                               6
Priority Scheduling

• Using Priority Scheduling we should schedule these
  processes according to the following Gantt chart

       P2   P5           P1                  P3        P4
   0        1        6                  16        18    19

• The average waiting time is 8.2 milliseconds
  i.e. (0+1+6+16+18)/5 = 8.2 milliseconds
  Priority can be defined internally or externally


                                                             7
Priority Scheduling

• Internally defined priorities use some measurable
  quantity or quantities to compute the priority of a
  process i.e.
   – Time limits

   – Memory requirements

   – Open files

   – The ratio of average I/O burst to average CPU burst

• Externally priorities are set by criteria process type,
  work, department sponsoring                               8
Priority Scheduling

• Priority scheduling can be either be Preemptive or Non
  Preemptive
• When a process arrives at the ready queue, its priority is
  compared with the priority of currently running process
• Preempt the CPU if the priority of the newly arrived
  process is higher than the priority of the currently
  running processes

                                                         10
Priority Scheduling

• If the priority scheduling algorithm is Non –
  Preemptive put the new process at the head of the
  ready queue
• A major problem with this is indefinite blocking

• A solution to this problem is Aging

• Aging is a technique which gradually increases the
  priority of processes that wait in the system for a
  long time                                             11
Round-Robin Scheduling Algorithm
• The round robin scheduling algorithm is designed

 especially for Time Sharing Systems
• It is similar to FCFS scheduling, but Preemption is added
 to switch between processes
• A small unit of time called Time quantum or time slice is
 defined
• A time quantum is generally from 10 to 100 mille seconds
• The CPU scheduler allocates the CPU to each process for
  a time interval of up to 1 time quantum
                                                      12
Round-Robin Scheduling Algorithm
• The average waiting time under Round Robin policy
  is often long
• Consider the following set of processes that arrive at
  time 0, with the
   – length of the CPU burst time given in milliseconds:
          Process                 Burst Time
            P1                     24
            P2                      3
            P3                      3


                                                           13
Round-Robin Scheduling Algorithm

• Use a time quantum of 4milliseconds
• Process P1 gets the first 4msec it is Preempted after the
  first time quantum
• P2 & P3 does not require 4msec they quit before their time
  quantum




                                                        14
Round-Robin Scheduling Algorithm

• The CPU is returned to process P1
• The average waiting time 17 / 3= 5.66milliseconds
• The average turn around time for 3 processes of time
  quantum 10 is 29




                                                         15
Round-Robin Scheduling Algorithm


• Round Robin scheduling is Preemptive
• If CPU burst time of process, is larger than the
  process time quantum then CPU is Preempted
  from the process
• No process is allocated CPU for more than 1 time
  quantum
Round-Robin Scheduling Algorithm


• Performance of RR scheduling depends on the
  size of time quantum
• If time quantum is extremely very large RR
  approach is same as FCFs
• If it is extremely small, RR approach is called
  processor sharing
                                                    18
Summary

In this class, you have learnt
• Priority Scheduling Algorithm

• Round Robin Scheduling




                                  19
Frequently Asked Questions

1. Explain Round Robin Scheduling

2. Explain Priority Scheduling

3. What are the Internal & External priorities




                                                 20
Quiz
1. In __________ scheduling CPU allocated to the
   process with the highest priority
a) FCFS
b) SJF
c) RR
d) Priority




                                               21
Quiz

2. Priority scheduling can be __________
a) Preemptive
b) Non Preemptive
c) Both
d) None




                                           22
Other subject materials
•   Web designing
•   Micro processors
•   C++ tutorials
•   java

home
Quiz

3. RR scheduling is designed for _______ systems
a)   Time sharing
b)   Real time
c)   Distributed
d)   None




                                                   24
Quiz

4. If the time quantum is extremely large than RR is
   same as
a) SJF
b) FCFS
c) Priority
d) None




                                                   25

20

  • 1.
    Understand Process Management •Process Scheduling Algorithms 1
  • 2.
    HOME PREVIOUS TOPIC NEXT PREVIOUS QUESTION PAPERS FOR OS CPP TUTORIALS 2
  • 3.
    Recap In the lastclass, you have learnt Shortest Job First scheduling algorithm and its -Advantages -Disadvantages 3
  • 4.
    Objectives On completion ofthis class, you would be able to know • Priority Scheduling • Round Robin Scheduling 4
  • 5.
    Priority Scheduling • Priorityscheduling algorithm is special case of SJF • A priority is associated with each process • Priorities are indicated by fixed range of numbers • In this scheduling CPU is allocated to the process with the highest priority • Equal priority process scheduled in FCFS order 5
  • 6.
    Priority Scheduling • Considerthe following set of processes assumed to have arrived at time 0, – in order P1,P2,P3-----P5 – with the length of the CPU burst time given in milliseconds – and their associated priorities Process Burst time Priorities P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 6
  • 7.
    Priority Scheduling • UsingPriority Scheduling we should schedule these processes according to the following Gantt chart P2 P5 P1 P3 P4 0 1 6 16 18 19 • The average waiting time is 8.2 milliseconds i.e. (0+1+6+16+18)/5 = 8.2 milliseconds Priority can be defined internally or externally 7
  • 8.
    Priority Scheduling • Internallydefined priorities use some measurable quantity or quantities to compute the priority of a process i.e. – Time limits – Memory requirements – Open files – The ratio of average I/O burst to average CPU burst • Externally priorities are set by criteria process type, work, department sponsoring 8
  • 10.
    Priority Scheduling • Priorityscheduling can be either be Preemptive or Non Preemptive • When a process arrives at the ready queue, its priority is compared with the priority of currently running process • Preempt the CPU if the priority of the newly arrived process is higher than the priority of the currently running processes 10
  • 11.
    Priority Scheduling • Ifthe priority scheduling algorithm is Non – Preemptive put the new process at the head of the ready queue • A major problem with this is indefinite blocking • A solution to this problem is Aging • Aging is a technique which gradually increases the priority of processes that wait in the system for a long time 11
  • 12.
    Round-Robin Scheduling Algorithm •The round robin scheduling algorithm is designed especially for Time Sharing Systems • It is similar to FCFS scheduling, but Preemption is added to switch between processes • A small unit of time called Time quantum or time slice is defined • A time quantum is generally from 10 to 100 mille seconds • The CPU scheduler allocates the CPU to each process for a time interval of up to 1 time quantum 12
  • 13.
    Round-Robin Scheduling Algorithm •The average waiting time under Round Robin policy is often long • Consider the following set of processes that arrive at time 0, with the – length of the CPU burst time given in milliseconds: Process Burst Time P1 24 P2 3 P3 3 13
  • 14.
    Round-Robin Scheduling Algorithm •Use a time quantum of 4milliseconds • Process P1 gets the first 4msec it is Preempted after the first time quantum • P2 & P3 does not require 4msec they quit before their time quantum 14
  • 15.
    Round-Robin Scheduling Algorithm •The CPU is returned to process P1 • The average waiting time 17 / 3= 5.66milliseconds • The average turn around time for 3 processes of time quantum 10 is 29 15
  • 17.
    Round-Robin Scheduling Algorithm •Round Robin scheduling is Preemptive • If CPU burst time of process, is larger than the process time quantum then CPU is Preempted from the process • No process is allocated CPU for more than 1 time quantum
  • 18.
    Round-Robin Scheduling Algorithm •Performance of RR scheduling depends on the size of time quantum • If time quantum is extremely very large RR approach is same as FCFs • If it is extremely small, RR approach is called processor sharing 18
  • 19.
    Summary In this class,you have learnt • Priority Scheduling Algorithm • Round Robin Scheduling 19
  • 20.
    Frequently Asked Questions 1.Explain Round Robin Scheduling 2. Explain Priority Scheduling 3. What are the Internal & External priorities 20
  • 21.
    Quiz 1. In __________scheduling CPU allocated to the process with the highest priority a) FCFS b) SJF c) RR d) Priority 21
  • 22.
    Quiz 2. Priority schedulingcan be __________ a) Preemptive b) Non Preemptive c) Both d) None 22
  • 23.
    Other subject materials • Web designing • Micro processors • C++ tutorials • java home
  • 24.
    Quiz 3. RR schedulingis designed for _______ systems a) Time sharing b) Real time c) Distributed d) None 24
  • 25.
    Quiz 4. If thetime quantum is extremely large than RR is same as a) SJF b) FCFS c) Priority d) None 25