Uniprocessor Scheduling - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Uniprocessor Scheduling

Description:

... an event occurs that may lead to blocking or preemption of the current process. ... Lack of preemption is not suited for time sharing environments ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 35
Provided by: engineerin54
Category:

less

Transcript and Presenter's Notes

Title: Uniprocessor Scheduling


1
Uniprocessor Scheduling
  • Chapter 9

2
Processor Scheduling
  • Processor scheduling determines the assignment of
    processes to be executed by the processor over
    time
  • Goals of scheduling
  • High processor utilization
  • less idle time
  • Fast throughput
  • large number of processes completed per unit time
  • Quick response time
  • small elapsed time from the submission of a
    request to the beginning of the response
  • Fairness
  • Low overhead

3
Classification of Scheduling Activity
  • Long-term which process to admit
  • Medium-term which process to swap in or out
  • Short-term which ready process to execute next

4
Queuing Diagram for Scheduling
5
Long-Term Scheduling
  • Determines which programs are admitted to the
    system for processing
  • Controls the degree of multiprogramming
  • Batch jobs
  • Whether to create a new process? If more
    processes are admitted
  • better CPU utilization - less likely that all
    processes will be blocked
  • each process has smaller fraction of the CPU time
  • Which job to admit next? May be based on
    priority, I/O requirements, etc.
  • The long term scheduler may attempt to keep a mix
    of processor-bound and I/O-bound processes

6
Long-Term Scheduling II
  • Interactive programs
  • E.g. user connecting to time-sharing system
  • Requests not queued up
  • Will accept new process requests until the system
    is saturated
  • When the system is full a new connection request
    is refused with an error message

7
Medium-Term Scheduling
  • Swapping decisions based on the need to manage
    multiprogramming
  • On systems with no virtual memory, the size of
    the process is also a criterion
  • Done by memory management software and discussed
    in chapters 7 and 8

8
Short-Term Scheduling
  • Determines which process is going to execute next
    (also called CPU scheduling)
  • The short term scheduler is known as the
    dispatcher
  • The scheduler is invoked whenever an event occurs
    that may lead to blocking or preemption of the
    current process. Example events
  • clock interrupts
  • I/O interrupts
  • operating system calls
  • signals

9
Short-Term Scheduling Criteria
  • Allocate processor time to optimize certain
    aspects of system behavior such as the following
    (Table 9.2)
  • User-oriented criteria perceived by a user or
    process
  • response time (interactive jobs), turn-around
    time (batch jobs)
  • System-oriented criteria
  • processor utilization, throughput
  • Performance-oriented (quantitative) readily
    measured
  • response time, throughput
  • Non-performance-oriented (qualitative)
  • predictability, fairness
  • Thus, the design of a scheduling policy involves
    compromising among several competing requirements
    and depends on the nature and use of the system

10
Definition of terms
  • Turnaround time
  • Interval of time between the submission of a
    process and its completion
  • Response time
  • Interval of time from submission of a request
    until the response begins to be received
  • Throughput
  • Number of processes completed per unit time
  • Processor utilization
  • Percentage of time the processor is busy
  • Fairness
  • In the absence of priorities, processes should be
    treated the same no process should starve

11
Using Priorities
  • Implemented by having multiple ready queues to
    represent each level of priority
  • Scheduler will always choose a process of higher
    priority over one of lower priority
  • Problem Lower-priority may suffer starvation
  • Then allow a process to change its priority based
    on its age or execution history
  • Our first scheduling algorithms will not make use
    of priorities
  • We will then consider other algorithms that use
    dynamic priority mechanisms

12
Characteristics of Scheduling Policies
  • The selection function determines which process
    in the ready queue is selected next for execution
  • The decision mode specifies the instants in time
    at which the selection function is exercised
  • Non-preemptive
  • Once a process is in the running state, it will
    continue until it terminates or blocks itself for
    I/O
  • Preemptive
  • Currently running process may be interrupted and
    moved to the Ready state by the OS
  • Allows for better service since any one process
    cannot monopolize the processor for very long
  • Greater overhead than non-preemptive ones

13
Example to discuss various scheduling policies
Service Time
Arrival Time
Process
1
0
3
2
2
6
3
4
4
4
6
5
5
8
2
Service time total processor time needed in one
CPU-I/O cycle Or Service time total execution
time required
14
First Come First Served (FCFS)
  • Selection function the process that has been
    waiting the longest in the ready queue (hence,
    FCFS) also known as FIFO
  • Decision mode non-preemptive
  • a process runs until it terminates or blocks
    itself

15
FCFS drawbacks
  • A process that does not perform any I/O will
    monopolize the processor
  • Favors CPU-bound processes
  • I/O-bound processes have to wait until CPU-bound
    process completes
  • They may have to wait even when their I/O are
    completed (poor device utilization)
  • We could have kept the I/O devices more busy by
    giving a bit more priority to I/O bound processes
  • FCFS is not an attractive policy on its own
    combine with priority scheme

16
Round-Robin (Time Slicing)
  • Selection function same as FCFS
  • Decision mode preemptive
  • a process is allowed to run until the time slice
    period (quantum, typically from 10 to 100 ms) has
    expired
  • then a clock interrupt occurs and the running
    process is put on the ready queue

17
Time Quantum for Round Robin
  • Length of the time slice is the principal design
    issue for round robin
  • Very short time quanta should be avoided because
    there is processing overhead involved in handling
    the clock interrupt and dispatching function
  • Should be slightly larger than a typical
    interaction time to get good response time

18
Round Robin Critique
  • Effective in a time-sharing or transaction
    processing system
  • Still favors CPU-bound processes
  • A I/O bound process uses the CPU for a time less
    than the time quantum and then is blocked waiting
    for I/O
  • A CPU-bound process runs for all its time slice
    and is put back into the ready queue (thus
    getting in front of blocked processes)
  • A solution virtual round robin (VRR)
  • When I/O is completed, the blocked process is
    moved to an auxiliary queue which has preference
    over the main queue
  • A process dispatched from the auxiliary queue
    runs no longer than the basic time quantum minus
    the time spent running since it was selected from
    the ready queue

19
Queuing for Virtual Round Robin
20
Shortest Process Next (SPN)
  • Selection function the process with the shortest
    expected processing time
  • Decision mode non-preemptive
  • Short processes are moved ahead of longer jobs in
    the queue
  • We need to estimate the required processing time
    (CPU burst time) for each process

21
Estimating average CPU burst
  • Simple averaging
  • Ti execution time for ith instance of this
    process (total execution time for batch job
    processor burst time for interactive job)
  • Si predicted value for ith instance
  • S1 predicted value for first instance not
    calculated

22
Estimating average CPU burst
  • Exponential averaging
  • Sn1 ?Tn (1 - ?)Sn (0 lt a lt 1)
  • Sn1 ?Tn (1 - ?)?Tn-1 (1 - ?)i?Tn-i
    (1 - ?)nS1
  • when ? is close to 1, weight is given to most
    recent observations
  • quickly reflect rapid change in observed quantity
  • when ? is smaller, the averaging is spread over
    several observations
  • Eg ? 0.8
  • Sn1 0.8Tn 0.16Tn-1 0.032Tn-2 0.0064Tn-3
  • S1 0 gives greater priority to new processes

23
(No Transcript)
24
S1 0
25
S1 0
26
Shortest Process Next Critique
  • Possibility of starvation for longer processes as
    long as there is a steady supply of shorter
    processes
  • Lack of preemption is not suited for time sharing
    environments
  • CPU bound process gets lower priority (as it
    should) but a process doing no I/O could still
    monopolize the CPU if it is the first one to
    enter the system
  • SPN implicitly incorporates priorities shortest
    jobs are given preferences

27
Shortest Remaining Time (SRT)
  • Selection function the process with the shortest
    expected remaining processing time
  • Decision mode preemptive
  • When a new process with a smaller remaining time
    enters the ready queue, the running process is
    preempted for the new process

28
Shortest Remaining Time Critique
  • Can be considered a preemptive version of SPN
  • Does not have a bias for longer processes
  • Risk of starvation of longer processes still
    exists
  • As with SPN, need an estimate of processing time
  • Also, elapsed service times must be recorded
    adds overhead
  • Gives better turnaround time than SPN because
    short jobs are given immediate preference

29
Highest Response Ratio Next (HRRN)
  • Selection function the process with largest
    value of response ratio (RR)
  • w time spent waiting for the processor
  • s expected service time
  • Decision mode non-preemptive

30
Highest Response Ratio Next Critique
  • Expected service time must be estimated as before
  • Shorter jobs are favored because they have
    smaller denominator (larger ratio)
  • Age of the process is also considered therefore,
    longer jobs do get a chance to get past competing
    shorter jobs
  • waiting time for longer jobs increases, thus RR
    increases and the longer job gets scheduled

31
Multilevel Feedback Scheduling
  • Preemptive scheduling (using time slices) with
    dynamic priorities
  • Several ready to execute queues with decreasing
    priorities P(RQ0) gt P(RQ1) gt ... gt P(RQn)
  • A new process is placed in RQ0
  • When it is preempted (finishes its time quantum),
    it is placed in RQ1. Next time it is preempted it
    is placed in RQ2 and so on, until it reaches RQn
  • I/O-bound (short) processes will stay in higher
    priority queues. CPU-bound jobs will drift
    downward.
  • Dispatcher chooses a process for execution in RQi
    only if RQi-1 to RQ0 are empty, hence longer jobs
    may starve

32
Multiple Feedback Queues
  • FCFS is used in each queue except for lowest
    priority queue where Round Robin is used

33
Time Quantum for feedback Scheduling
  • With a fixed quantum time, the turnaround time of
    longer processes can stretch out alarmingly
  • To compensate we can increase the time quantum
    according to the depth of the queue (RQi 2i)
  • Longer processes may still suffer starvation.
    Possible fix promote a process to higher
    priority after some time

34
Algorithm Comparison
  • Which one is best?
  • The answer depends on various factors such as
  • the system workload (extremely variable)
  • relative weighting of performance criteria
    (response time, CPU utilization, throughput...)
  • Summary of algorithms See
  • Table 9.3
  • Table 9.5, Figure 9.5
Write a Comment
User Comments (0)
About PowerShow.com