elg6171SchedulingPresentation
-
Upload
ekta-khandelwal -
Category
Documents
-
view
215 -
download
0
Transcript of elg6171SchedulingPresentation
-
8/3/2019 elg6171SchedulingPresentation
1/19
Ekta Khandelwal
1060
M.Tech CS&E
-
8/3/2019 elg6171SchedulingPresentation
2/19
Problem definition: One CPU with a number of processes. Only one
process can use the CPU at a time and each processis specialized in one, and one task. Whats the best
way to organize the processes (schedule them) ?[1]
How will the CPU time be divided among theprocesses and threads competing to use it ? [2]
No one right approach Many different criteria for different situations
Many different factors to optimize
-
8/3/2019 elg6171SchedulingPresentation
3/19
A pool of runnable processes are contending forone CPU;
The processes are independent and compete forresources;
The job of the scheduler is to distribute the scarceresource of the CPU to the different processesfairly and in an optimal way;
The job of the dispatcher is to provide the
mechanismfor running the processes; The OS is a multitasking, but not a multiprocessor,
one;
-
8/3/2019 elg6171SchedulingPresentation
4/19
CPU utilization Keep it as high as
possible
Throughput Number of processes
completed per unit
time
Waiting time Amount of time spentready to run but not
runnin
Response time Amount of time
between submission of
requests and first
response to the request
Scheduler efficiency Minimize the
overheadTurnaround time Mean time from
submission to
-
8/3/2019 elg6171SchedulingPresentation
5/19
Resources: Preemptible:
Take resource away,use it for something
else, then give it back.(e.g. processor or I/Ochannel)
Non-preemptible: Once give, it cant be
reused until processgives it back. (e.g. filespace or terminal)
Processes: IO bound:
Perform lots of IOoperations.
CPU bound: Perform lots of
computation and dolittle IO
-
8/3/2019 elg6171SchedulingPresentation
6/19
The states of a process, atany given time, iscomprised of thefollowing minimal set: Running:
The CPU is currentlyexecuting the codebelonging to the process.
Ready:
The process could be
running, but anotherprocess has the CPU.
Waiting:
Before the process can run,some external event mustoccur.
-
8/3/2019 elg6171SchedulingPresentation
7/19
First-Come First-Serve (FCFS) One ready queue;
OS runs the process at head of the queue;
New processes come in at the end of the queue;
Running process does not give up the CPU until itterminates or it performs IO.
Round Robin Process runs for one time slice, then moved to back of
the queue; Each process gets equal share of the CPU.
-
8/3/2019 elg6171SchedulingPresentation
8/19
Priority Systems The highest priority ready process is selected
In case of a tie, FCFS can be used
Priorities could be assigned:
Externally (e.g. by a system manager)
Internally (e.g. by some algorithm)
Combination of external and internal
Preemptive schemes: Once a process starts executing, allow it to continue until it
voluntarily yields the CPU
Non-preemptive schemes:
A running process may be forced to yield the CPU by anexternal event rather than by its own action
-
8/3/2019 elg6171SchedulingPresentation
9/19
Non-preemptive FCFS (no priority scheme) Simplest implementation of scheduling algorithms
Used on timeshared systems (with timer interruption)
Non-preemptive FCFS (with priority scheme)
Next highest priority process is picked when CPU is yielded
Once process grabs CPU, former keeps latter untilcompletion
Rarely used in real-time systems
Preemptive FCFS (with priority scheme)
Most popular FCFS algorithm
-
8/3/2019 elg6171SchedulingPresentation
10/19
Allows multiple users
slices of the CPU on around robin basis
Majority of users havethe same priority
Not a popular schemewith dynamic prioritysystems
-
8/3/2019 elg6171SchedulingPresentation
11/19
For each process, identify duration (i.e., length) ofits next CPU burst.
Use these lengths to schedule process withshortest burst
Two schemes: Non-preemptive once CPU given to the process, it is not
preempted until it completes its CPU burst Preemptive if a new process arrives with CPU burst length
less than remaining time of current executing process,
preempt. This scheme is known as the Shortest-Remaining-Time-First
(SRTF)
-
8/3/2019 elg6171SchedulingPresentation
12/19
of long one. SJF is provably optimal gives
minimum average waiting timefor a given setof process bursts Moving a short burst ahead of a long one reduces
wait time of short process more than it lengthenswait time
-
8/3/2019 elg6171SchedulingPresentation
13/19
SchedulingCS-502 Fall 2007 13
P1 P3 P2
73 160
P4
8 12
ProcessArrival TimeBurst TimeP1 0.0 7P2 2.0 4P3 4.0 1
P4 5.0 4 SJF (non-preemptive)
Average waiting time = (0 + 6 + 3 + 7)/4= 4
-
8/3/2019 elg6171SchedulingPresentation
14/19
SchedulingCS-502 Fall 2007 14
ProcessArrival TimeBurst TimeP1 0.0 7P2 2.0 4P3 4.0 1P
45.0 4
SJF (preemptive)
Average waiting time = (9 + 1 + 0 +2)/4 =3
P1 P3P2
42 110
P4
5 7
P2 P1
16
-
8/3/2019 elg6171SchedulingPresentation
15/19
SchedulingCS-502 Fall 2007 15
A priority number (integer) is associated witheach process
CPU is allocated to the process with the
highest priority (smallest integer highestpriority) Preemptive
nonpreemptive
-
8/3/2019 elg6171SchedulingPresentation
16/19
SchedulingCS-502 Fall 2007 16
(Usually) preemptive Process are given prioritiesand ranked
Highest priority runs next May be done with multiple queues multilevel
SJF= priority scheduling where priority isnext predicted CPU burst time
Recalculate priority many algorithms E.g. increase priority of I/O intensive jobs E.g. favor processes in memory Must still meet system goals e.g. response time
-
8/3/2019 elg6171SchedulingPresentation
17/19
SchedulingCS-502 Fall 2007 17
Problem: Starvation low priority processesmay never execute
Solution: Aging as time progresses, increasepriority of waiting processes
-
8/3/2019 elg6171SchedulingPresentation
18/19
SchedulingCS-502 Fall 2007 18
General theme what is the best way torun nprocesses on kresources? ( k< n)
Conflicting Objectives no one best way Latency vs. throughput Speed vs. fairness
Incomplete knowledge E.g. does user know how long a job will take
Real world limitations E.g. context switching takes CPU timeJob loads are unpredictable
-
8/3/2019 elg6171SchedulingPresentation
19/19