View
219
Download
0
Category
Tags:
Preview:
Citation preview
Operating System Concepts and
Techniques Lecture 7
Scheduling-3
M. Naghibzadeh
ReferenceM. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011.
To order: www.iUniverse.com, www.barnesandnoble.com, or www.amazon.com
2
Computation of Turnaround Time (TT)
Turnaround Time: is the time span starting from when a request is submitted and ending
whenever the requested execution is completedWe take Average TT to be the only performance
measure of schedulersThree schedulers FCFS, SPN, and RR will be
consideredA system with the following three processes is
examined
Process Arrival time CPU burst
P1 10 4
P2 11 3
p3 12 2
FCFS schedulerThe following table shows how
FCFS behaves
3
Process Arrival time CPU burst Completion time
Turnaround time
P1 10 4 14 4
P2 11 3 17 6
P3 12 2 19 7
Single-programming and FIFO scheduling
Average turnaround time = 17/3 = 5.66
SPN schedulerThe following table shows how SPN behaves
With SPN, whenever a scheduling decision has to be made, the decision is based on available
information, not of future information, therefore at time 10 process 1 is picked but at time 14 process
3 is picked
4
Single-programming and SPN scheduling
Average turnaround time = 16/3 = 5.33
Process Arrival time CPU burst Completion time
Turnaround time
P1 10 4 14 4
P2 11 3 19 8
P3 12 2 16 4
RR schedulerThe following chart shows how SPN behaves
When processes do not have any I/O operation and do not have to wait for any event, RR scheduler may perform worse than FCFS and
SPNIn cases of I/O, depending on average CPU wait ration, usually RR
performs better
5
Multi-programming and RR scheduling
Average turnaround time = 23/3 = 7.66
10.0 11.0 12.0 18.0 19.0 Time
1.0 0.5 2.0 0.5
0.5 2.0 0.5
Processes
P3
P2
P1
2.0
RR for Processes with I/OHere, we consider the same set of tasks but the average I/O ratio
w=0.4, i.e., when there is only one process 40% of CPU time is wastedWhen there are two processes CPU wait fraction is w2=0.16 hence 84%
of CPU time is useful, every process’s share is 42%When there are three processes CPU wait fraction is w3=0.064 hence
approximately 94% of CPU time is useful, every process’s share is 31.3%
6
Multi-programming and RR scheduling with w=0.4
Average turnaround time = 8.55
10.00 11.00 12.00 18.41 19.79 20.46 Time
0.6 0.42 2.0 0.58 0.4
0.42 2.0 0.58
Processes
P3
P2
P1
2.0
Disk I/O SchedulingDisks have their own special schedulersUnit of work is reading/writing a sectorDisks constantly receive requests from
different processesRequest arrivals is not uniform; therefore a pool for outstanding
requests is neededDisk scheduler decides which request to pick from the pool when the disk head is
finished its previous request
7
Disk propertiesThe simplest kind of disk is a one surface with one
moving headIt is composed of many concentric tracks with every track having the same number of sectors, see below
8
Track
Sector
Moving head
Reading/writing a sectorReading/Writing a sector comprises
Seek time: the time length for the read/write head to move from current position to the desired track
Rotational delay: is the length of time for the beginning of sector to reach the read/write head,
after the head has settled on the desired track Average rotational delay is considered to be half the time
of one complete disk rotation Transfer time: The time to transfer one sector of
data depends on the rotation speed, track capacity, and sector size, This is equal to:
9
timeRotationcapacityTrack
sizeBlocktimetransferBlock
SchedulersRotational delay and transfer time is
fixedThe performance of a disk scheduler thus depends on the order in which outstanding requests are answered
A track trace is set of requests in the order of arrival
We study, FIFO, LIFO, SSTF, Scan, C-Scan schedulers
10
FIFO
11
From 50 34 57 28 65 190 120 163 163 180
To 34 57 28 65 190 120 163 163 180 46
Seek length
16 23 29 37 125 70 43 0 17 134 Total = 494
Track trace 34, 57, 28, 65, 190, 120, 163, 163, 180, 46
Let’s assume head’s current position is on track 50
The shortest seek length for is zero The longest seek length is n-1With FIFO there is no risk of starvationNew request may not be served before existing ones
LIFO
12
From 50 34 57 28 65 190 120 163 163 180
To 34 57 28 65 190 120 163 163 180 46
Seek length
16 23 29 37 125 70 43 0 17 134 Total = 494
Track trace 34, 57, 28, 65, 190, 120, 163, 163, 180, 46
Let’s assume head’s current position is on track 50
The shortest seek length for is zero The longest seek length is n-1 An existing request may never get the chance to be executed because new requests keep coming, dtarvation With LIFO, arrival of new requests causes the serving of previous ones to delay
Shortest Service Time First
13
Track trace 34, 57, 28, 65, 190, 120, 163, 163, 180, 46
Let’s assume head’s current position is on track 50
The shortest seek length for is zero The longest seek length is n-1 SSTF may cause starvation for some requestsWith SSTF, arrival of new requests may cause the serving of previous ones to delay
From 50 46 57 65 34 28 120 163 163 180
To 46 57 65 34 28 120 163 163 180 190
Seek length
4 11 8 31 6 92 43 0 17 10 Total = 222
Scan
14
Track trace 34, 57, 28, 65, 190, 120, 163, 163, 180, 46
Let’s assume head’s current position is on track 50
The shortest seek length for is zero The longest seek length is n-1. Scan is considered starvation-freeWith SSTF, arrival of new requests may cause the serving of previous ones to delay
From 50 57 65 120 163 163 180 190 46 34
To 57 65 120 163 163 180 190 46 34 28
Seek length
7 8 55 43 0 17 10 144 12 6 Total = 302
C-Scan
15
Track trace 34, 57, 28, 65, 190, 120, 163, 163, 180, 46
Let’s assume head’s current position is on track 50
The shortest seek length for is zero The longest seek length is n-1. Scan is considered starvation-freeWith SSTF, arrival of new requests may cause the serving of previous ones to delay
From 50 57 65 120 163 163 180 190 28 34
To 57 65 120 163 163 180 190 28 34 46
Seek length
7 8 55 43 0 17 10 162 6 12 Total = 320
SummaryA scheduling strategy is usually designed to
attain a defined objective, although multi-objective strategies are also possible
Average turnaround time (ATT) may be used to estimate the expected time length in which a request is completed after being submitted to
the system; this could be a good measure of performance
Based on ATT different scheduling algorithms were investigated
Besides, in this chapter, I/O scheduling was studied and different schedulers such as FIFO, LIFO, SSTF, Scan, and C-Scan were introduced
16
17
Find outHow ATT is computed for nonpreemptive
schedulers such as FIFO and SJN where w0How FIFO, SJN, and RR behave with respect to
throughputHow I/O schedulers work for two-surface disks
How I/O schedulers work for disk packs, i.e., disks with multiple plates each having two
surfacesHow I/O schedulers work for multiples
Read/write heads per surfaceWhat the role of cylinders are with respect to
I/O schedulers
18
Any questions?
Recommended