Non Preemptive Scheduling Limitations - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Non Preemptive Scheduling Limitations

Description:

... Based Scheduling ( Priority may be pre-fixed Deadline ) difficult to implement. ... Different Priority Levels with a Pre-Fixed Time Quantum allotted to each ... – PowerPoint PPT presentation

Number of Views:131
Avg rating:3.0/5.0
Slides: 21
Provided by: hardwa
Category:

less

Transcript and Presenter's Notes

Title: Non Preemptive Scheduling Limitations


1
Non Pre-emptive Scheduling Limitations
  • The Currently Running process may dominate the
    CPU causing all the Other Processes to starve.
  • Will have a profound effect on the Response Times
    of ALL the processes except the very first
    Process i.e. the process which gets to run first.
  • Except for FCFS and Priority Based Scheduling (
    Priority may be pre-fixed Deadline ) difficult to
    implement.
  • The Number of process chunks in the READY Queue
    is NOT fixed and new chunks may arrive
    continuously hence a single READY Queue may
    become too large to manage.

2
Pre-emptive Scheduling Strategies Adopted - 1
  • Time share the CPU among the Process Chunks i.e.
    use a Round Robin Scheduling Policy with each
    process chunk allocated a pre-fixed Time Slice
    supported by a Dedicated Interval Timer.
  • Stick to pre-assigned Priority based scheduling
    with a fixed number of Pre-Assigned Priorities.
  • Use several Ready Queues one for each Priority
    Level.
  • CPU Time is distributed in a Round Robin Fashion
    among the Different Priority Levels with a
    Pre-Fixed Time Quantum allotted to each Priority
    Level. Hence each Ready Queue possesses two (2)
    associated attributes , The Priority Level (Pr)
    and the associated Time Slice (T).
  • Within one Ready Queue i.e. for the Processes
    having same priority the Process Chunks are
    serviced also in a Round Robin fashion based on
    their Arrival ( normally FCFS).

3
Round Robin Policyfor One Ready Queue
  • The Short Term Scheduler maintains a Ready Queue
    of PCBs as well as a List of PCBs of ALL Blocked
    and Swapped Out Processes.
  • The PCB of a newly created process is added to
    the end of the Ready Queue (FCFS policy) . The
    PCB of a terminated process is removed from all
    the associated Lists.
  • The Scheduler always selects the Process Chunk
    whose PCB is at the Head of the Ready Queue.
  • This process is allowed to run for its prefixed
    time slice.
  • On completion of this Time slice , a Timer
    Interrupt is generated causing pre-emption of
    that running process and puts its PCB at the
    end of the Ready Queue.
  • The Event Handler / Interrupt Handler performs
    the following actions
  • (a) Whenever the currently Running
    Process makes any I/O request , or is swapped out
    of memory its PCB is removed from the Ready Queue
    and inserted at the back of the list of Blocked
    and Swapped Out Processes.
  • (b) Whenever the I/O operation awaited
    by a process finishes , or the process is swapped
    in , its PCB is removed from the Blocked and
    Swapped Out List and put at the end of the Ready
    Queue.

4
Pre-emptive Priority based Scheduling Multiple
Ready Queues , Assumptions
  • As soon as any new process is brought in the
    memory by the Medium Term Scheduler, the
    following events take place in sequence
  • a) The currently running process if
    unfinished is brought back at
  • the Front of its respective Ready
    Queue.
  • b) The Enqueuer is brought into execution
    (running state) after
  • a context switch which brings the
    newly arrived process at
  • the back of its respective Ready
    Queue.
  • c) Next the Dispatcher is invoked in order
    to select the process
  • based on the scheduling policy
    illustrated before i.e.
  • remaining part of the Time Quantum
    allocated to the
  • previously running process is LOST.
  • d) However , once ALL process Chunks has
    arrived (rare occurrence) then perfect Round
    Robin Policy is followed among the different
    Priority Levels and minimum Time allotted to
    each process is one Time Quantum as allocated to
    that priority level.

5
Timer generated Interrupt ( an essential feature
of Pre-empted Scheduling Policy / Multitasking - 1
  • Implemented by an interrupt timer device The
    code outline
  • A. Setting the Time Interval by the user / O.S
  • Set Interval ( lt programmable value gt )
  • / begin set interval done as a part of
    Context Switch /
  • k lt Pre-Fixed Time Quantum gt / Global
    variable /
  • Interrupt_count k / Global variable /
  • / end set interval /

6
Timer generated Interrupt ( an essential feature
of Pre-empted Scheduling Policy / Multitasking - 2
  • Interval-Timer ( ) / will cause the
    Programmable Interrupt Timer Device to issue on
    interrupt once on every k clock ticks /
  • / begin repeatedly invoked within the
    running process/
  • while (Interrupt_count gt 0)
  • / begin while /
  • Interrupt_count Interrupt_count
    1
  • / end while /
  • Int_Request TRUE / Issue
    Interrupt on Reaching 0 Count/
  • / end /
  • In actual terms one can have a hardware support
    available in a programmable interrupt controller
    (like APSC in Pentium)

7
Pre-emptive Priority Based Scheduling Case
Study- 1
  • Consider the following Process mix
  • (Lower Number implies Higher Priority )
  • --------------------------------------------------
    ----------------------------------
  • Process Arrival Time Service time
    Pre-Assigned
  • Chunk No. in units in units
    Priority
  • --------------------------------------------------
    ----------------------------------
  • P0 80 200
    1
  • P1 10 400
    3
  • P2 130 250
    1
  • P3 60 500
    4
  • P4 200 300
    2
  • --------------------------------------------------
    -----------------------

8
Pre-emptive Priority based Scheduling Case Study
- 2
  • Consider the Process mix to be scheduled in order
    of arrival.
  • --------------------------------------------------
    ----------------------------------
  • Process Arrival Time Service time
    Pre-Assigned
  • Chunk No. in units in units
    Priority
  • --------------------------------------------------
    ----------------------------------
  • P1 10 400
    3
  • P3 60 500
    4
  • P0 80 200
    1
  • P2 130 250
    1
  • P4 200 300
    2
  • --------------------------------------------------
    -----------------------

9
Pre-emptive Priority based Scheduling Round
Robin Policy Outline
  • --------------------------------------------------
    ----------------------------------
  • Pre-Assigned Process Process
    Pre-Assigned Time
  • Priority Chunks Types
    Slice
  • --------------------------------------------------
    ----------------------------------
  • 1 P0, P2
    Short, CPU Bound Short, Many
  • 2 P4
    Medium Sized Medium , Medium
  • 3 P1
    Slightly Higher Size Large, Less
  • 4 P3
    Long Largest, Minimum
  • --------------------------------------------------
    -----------------------

10
Pre-emptive Priority based Scheduling Round
Robin Policy Outline
  • Scheduler takes up processes from each Priority
    Queue in Turn i.e. in a Round Robin Fashion .
  • Among all the processes in a Particular Priority
    the Servicing Policy is FCFS.
  • No particular Priority should dominate the CPU
    time thereby forcing the other Processes in
    remaining Priority levels to starve.
  • Each priority level should be assigned a Fixed
    Percentage Quota of CPU Time.

11
Pre-emptive Priority based Scheduling Case
Study - 3
  • Four different Levels of Priority (1..4) with
    lower number implying Higher Priority.
  • Servicing Policy CPU goes round robin in the
    following manner
  • Within the same queue, round robin based on the
    First Come First Serve (FCFS) basis.
  • CPU moves among the different queues with
    prefixed number of Time Slice allocation as
    depicted below
  • Priority Level CPU Time(Approx)
    Implication
  • 1. 40
    4 Time slices of 10
  • 2. 30
    2 Time slices of 20
  • 3. 20
    1 Time slice of 30
  • 4. 10
    1 Time slice of 40
  • N.B Higher Priority Process Chunks gets more
    number of Smaller Sized Chunks .

12
Pre-emptive Priority based Scheduling Policy
Outline
  • CPU starts from Priority Level 1 then cycles
    through the remaining Priority Levels.
  • If any Priority Level is empty then any remaining
    Time Slice allotted for that level is NOT used up
    and Scheduler goes to the next lower priority
    level.
  • If any of the processes at a priority level
    remains unfinished even after ALL the allotted
    Time Slice to that priority level has been used
    up then it may do the two following things
  • a) It MUST wait for its turn in
    the NEXT Cycle Non Feedback Queues
  • b) All the unfinished processes in
    any Priority Level I is put at the back end of
    the next Priority Level Queue hoping to get any
    unused Time slice in that Priority level
    Feedback Queue .
  • 4. If after allocating any time slice to the
    dispatched process, any new process arrives in
    the Ready Queue then that running user process
    gets pre-empted, the left over of the allotted
    time slice to that process is LOST and Enqueuer
    gets invoked.

13
Pre-emptive Priority based Scheduling 5 Non
Feedback Multiple Ready Queues
  • Various Queue Structures

P2 250 Units Service P0 200 Units Service
Arrived at 130 Arrived at 80
Priority Level 1 Queue Time slice 10 Units X
4
P4 300 Units Service Arrived at 200
Priority Level 2 Queue Time slice 20 Units X
2
P1 400 Units Service Arrived at 10
Priority Level 3 Queue Time slice 30 Units X
1
P3 500 Units Service Arrived at 60
Priority Level 4 Queue Time slice 40
Units X 1
14
Non Pre Emptive Scheduling Policies Common
Assumptions - 1
  • Assume Context switching time 1 unit (fixed).
  • Dispatcher Execution time 3 units
    (fixed).
  • Enqueuer Execution time 2 units
    (fixed).

15
Pre-emptive Priority based Scheduling 6 All
Types of Multiple Ready Queues
  • Dispatcher Enqueuer Block Structures

Context Switch Dispatcher Context Switch 1 Unit
3 Units 1 Unit
Context Switch Enqueuer Context Switch 1 Unit
2 Units 1 Unit

16
Pre-emptive Priority based Scheduling 7 Non
Feedback Multiple Ready Queues
  • The GANTT Chart

EnQ P1 (Pr3)
P1(Pr 3) 30 Done 370 Left
EnQ P3 (Pr4)
DiS P1
P1(Pr 3) 7 Done 363 Left
DiS P3
DiS P1
10 13 18
48 53 60
63 68
EnQ P0 (Pr1)
DiS P0
P0(Pr 1) 10 Done 190 Left
DiS P0
P3(Pr 4) 12 Done 488 Left
P0(Pr 1) 10 Done 180 Left
68 80 83
88 98 103
113
17
Pre-emptive Priority based Scheduling 8 Non
Feedback Multiple Ready Queues
  • The GANTT Chart Contd.

P0(Pr 1) 30 Done 170 Left
DiS P0
DiS P1
DiS P0
EnQ P2 (Pr1)
P0(Pr 1) 40 Done 160 Left
113 118 128 133
136 146 151
P1(Pr 3) 66 Done 334 Left
P3(Pr 4) 26 Done 474 Left
DiS P3
EnQ P4 (Pr2)
DiS P0
151 181 186
200 203 208
18
Pre-emptive Priority based Scheduling 9 Non
Feedback Multiple Ready Queues
  • The GANTT Chart Contd.

P0(Pr 1) 50 Done 150 Left
DiS P2
DiS P0
P2(Pr 1) 10 Done 240 Left
208 218 223
233 238
P2(Pr 1) 20 Done 230 Left
DiS P2
DiS P4
P2(Pr 1) 60 Done 140 Left
238 248 253
263 268
19
Pre-emptive Priority based Scheduling 10 Non
Feedback Multiple Ready Queues
  • The GANTT Chart Contd.

DiS P4
DiS P1
P4(Pr 2) 20 Done 280 Left
P4(Pr 2) 40 Done 260 Left
P1(Pr 3) 30 Done 334 Left
268 288 293
313 318
348
DiS P0
DiS P3
P3(Pr 4) 40 Done 437 Left
P0(Pr 1) 70 Done 130 Left
DiS P2
348 353 393
398 408 413
20
Scheduling Policiesincluded in the Syllabus
Self Study
  • Scheduling Policy adopted in UNIX Fair Share
    Policy
  • Scheduling Policy adopted in LINUX
  • Real Time Scheduling
  • Non Real Time Scheduling
  • 3. Scheduling Policy adopted in WINDOWS XP.
Write a Comment
User Comments (0)
About PowerShow.com