Académique Documents
Professionnel Documents
Culture Documents
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland Copyright © 1998-2001 by Eskicioglu & Marsland 1
Scheduling Scheduling
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 2 Copyright © 1998-2001 by Eskicioglu & Marsland 3
Scheduling Scheduling
Life cycle of a typical process Long- & medium-term scheduling
Long Short Medium
Acting as the primary resource allocator, the long-
Term active Term blocked Term swapped term scheduler admits more jobs when the resource
Scheduling Scheduling Scheduling
utilization is low, and blocks the incoming jobs from
process
arrives
entering the ready queue when utilization is too high.
When the main memory becomes over-committed,
the medium-term scheduler releases the memory of a
suspended (blocked or stopped) process by swapping
(rolling) it out.
In summary, both schedulers control the level of
multiprogramming and avoid (as much as possible)
overloading the system by many processes and cause
‘‘thrashing’’ (more on this later).
process
exits
Jan’0 1
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 4 Copyright © 1998-2001 by Eskicioglu & Marsland 5
Scheduling Scheduling
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 6 Copyright © 1998-2001 by Eskicioglu & Marsland 7
Scheduling Scheduling
Scheduler design Scheduling policies
A typical scheduler is designed to select one or more In general, scheduling policies may be preemptive or
primary performance criteria and rank them in order of non-preemptive.
importance. One problem in selecting a set of performance
criteria is that they often conflict with each other. For In a non-preemptive pure multiprogramming system,
example, increased processor utilization is usually achieved the short-term scheduler lets the current process run
by increasing the number of active processes, but then
response time deteriorates. So, the design of a scheduler until it blocks, waiting for an event or a resource, or it
usually involves a careful balance of all requirements and terminates.
constraints.
Preemptive policies, on the other hand, force the
The following is only a small subset of possible currently active process to release the CPU on certain
characteristics:
events, such as a clock interrupt, some I/O interrupts,
I/O throughput, CPU utilization, response time (batch or or a system call.
interactive), urgency of fast response, priority,
maximum time allowed, total time required.
Jan’0 1
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 8 Copyright © 1998-2001 by Eskicioglu & Marsland 9
Scheduling Scheduling
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 10 Copyright © 1998-2001 by Eskicioglu & Marsland 11
Scheduling Scheduling
An example—FCFS Shortest Job First (SJF)
process service turnaround waiting SJF policy selects the job with the shortest
time ts time tt time tw
A 10 10 0 (expected) processing time first. Shorter jobs are
B 1 11 10
process C 3 14 11 always executed before long jobs.
D 4 18 14
AVERAGE 13.25 8.75 One major difficulty with SJF is the need to know or
tt / t w = 1.51 tt / t s = 5.29 estimate the processing time of each job (can only
A 10 predict the future!)
B 1
Also, long running jobs may starve, because the CPU
C 3
has a steady supply of short jobs.
D 4
time
5 10 1 20 25
5
Jan’0 1
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 12 Copyright © 1998-2001 by Eskicioglu & Marsland 13
Scheduling Scheduling
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 14 Copyright © 1998-2001 by Eskicioglu & Marsland 15
Scheduling Scheduling
An example—RR Priority-based
Quantum = 1
process service turnaround waiting Each process is assigned a priority. The ready list
time ts time tt time tw
A 10 18 8 contains an entry for each process ordered by its
B 1 2 1
process C 3 9 6 priority. The process at the beginning of the list
D 4 12 8
(highest priority) is picked first.
AVERAGE 10.25 5.75
t t / t w = 1.78 tt / t s = 2.45 A variation of this scheme allows preemption of the
A 1 1 1 1 6 current process when a higher priority process
B 1 arrives.
C 1 1 1 Another variation of the policy adds an aging scheme,
D 1 1 1 1 where the priority of a process increases as it remains
in the ready queue; hence, will eventually execute to
5 10 1 20 25
time completion.
5
Jan’0 1
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 16 Copyright © 1998-2001 by Eskicioglu & Marsland 17
Scheduling Scheduling
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 18 Copyright © 1998-2001 by Eskicioglu & Marsland 19
Scheduling Scheduling
Other policies Multi-level queue
As discussed earlier, the previous policies cannot Multi-Level Queue (MLQ) scheme solves the mix job
efficiently handle a mixed collection of jobs (e.g., problem by maintaining separate ‘‘ready’’ queues for
batch, interactive, and CPU-bound). So, other each type of job class and apply different scheduling
schemes were developed: algorithms to each.
• Multi-level queue scheduling job classes
highest primary CPU
• Multi-level feedback queue scheduling priority
system processes
priority-based
scheduling
Round-Robin
interactive processes CPU
FCFS
background processes
lowest
priority
Jan’0 1
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 20 Copyright © 1998-2001 by Eskicioglu & Marsland 21
Scheduling Scheduling
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 22 Copyright © 1998-2001 by Eskicioglu & Marsland 23
Scheduling Scheduling
Real-time tasks Multiprocessor scheduling
A process (usually referred to as a task in R-T • thread scheduling
systems) that controls or reacts to an event in a R-T • load sharing/balancing
system is associated with a deadline specifying either • gang scheduling
a start time or a completion time. Depending on its
• dedicated processor assignment
deadline, a process can be classified as one of the
following: • dynamic scheduling
• Hard real-time
– must meet the deadlines (time-critical).
• Soft real-time
– meeting a deadline is desirable (better performance).
Jan’0 1
Jan’0 1
Copyright © 1998-2001 by Eskicioglu & Marsland 24 Copyright © 1998-2001 by Eskicioglu & Marsland 25
Scheduling Scheduling