38
1 Disk Scheduling Because Disk I/O is so important, it is worth our time Investigate some of the issues involved in disk I/O. One of the biggest issues is disk performance.

1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

Embed Size (px)

Citation preview

Page 1: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

1

Disk SchedulingDisk Scheduling

Because Disk I/O is so important, it is worth our time toInvestigate some of the issues involved in disk I/O.

One of the biggest issues is disk performance.

Page 2: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

2

seek time is the timerequired for the read head tomove to the track containingthe data to be read.

Page 3: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

3

rotational delay orlatency, is the time required for the sectorto move under the read head.

Page 4: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

4

Performance ParametersPerformance Parameters

Wait for device

Wait forChannel

Device busy

seek

rotationaldelay data

transfer

Seek time is the time required tomove the disk arm to the specified track

Ts = # tracks * disk constant + startup time~

Rotational delay is the time required for the data onthat track to come underneath the read heads. Fora hard drive rotating at 3600 rpm, the average rotationaldelay will be 8.3ms.

Transfer Time

Tt = bytes / ( rotation_speed * bytes_on_track )

(latency)

Page 5: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

5

Data Organization vs. Performance

Data Organization vs. Performance

Consider a file where the data is stored as compactly as possible, in this example the file occupies all of the sectors on 8 adjacent tracks (32 sectors x 8 tracks = 256 sectors total).

The time to read the first track will be

average seek time 20 ms rotational delay 8.3 ms read 32 sectors 16.7 ms

Assuming that there is essentially no seek time on the remaining tracks,each successive track can be read in 8.3 + 16.7 ms = 25ms.

Total read time = 45ms + 7 * 25ms = 220ms = 0.22 seconds

45ms

Page 6: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

6

If the data is randomly distributed across the disk:

For each sector we have

average seek time 20 ms rotational delay 8.3 ms read 1 sector 0.5 ms

Total time = 256 sectors * 28.8 ms/sector = 7.73 seconds

28.8 ms

Page 7: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

7

In the previous example, the biggest factoron performance is ?

Seek time!

To improve performance, weneed to reduce the average seek time.

Page 8: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

8

Queue

Request

Request

Request

Request

The operating system keeps a queue of requests to read/write the disk.

In these exercises we assume that allof the requests are on the queue.

Page 9: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

9

Queue

Request

Request

Request

Request

If requests are scheduled in random order,then we would expect the disk tracks to be

visited in a random order.

Page 10: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

10

Queue

Request

Request

Request

Request

If there are only a few processes competing for the drive, then we can hope for good performance.

If there are a large number of processes competing for the drive, then performance approaches the random scheduling case.

First-come, First-served Scheduling

Page 11: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

11

Track

10

20

30

40

15 to 4 114 to 40 3640 to 11 2911 to 35 2435 to 7 287 to 16 9

137 tracks

While at track 15, assume some random set of read requests -- tracks 4, 40, 11, 35, 7 and 16

Head Path Tracks Traveled

Page 12: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

12

Queue

Request

Request

Request

Request

Shortest Seek Time First

Always select the request that requires the shortest seek time from the current position.

Page 13: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

13

Track

10

20

30

40

While at track 15, assume some random set of read requests -- tracks 4, 40, 11, 35, 7 and 16

Shortest Seek Time First

Problem?

In a heavily loaded system, incoming requests with ashorter seek time will constantly push requests with long seek times to the end of the queue. This resultsIn what is called “Starvation”.

Head Path Tracks Traveled

Page 14: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

14

Track

10

20

30

40

50 100

While at track 15, assume some random set of read requests -- tracks 4, 40, 11, 35, 7 and 16

Shortest Seek Time First

Problem?

In a heavily loaded system, incoming requests with ashorter seek time will constantly push requests with long seek times to the end of the queue. This resultsIn what is called “Starvation”.

Head Path Tracks Traveled

15 – 16 116 – 11 511 – 7 47 – 4 34 – 35 3135 – 40 5

49 tracks

Page 15: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

15

Queue

Request

Request

Request

Request

The elevator algorithm (scan-look)

Search for shortest seek time from the current position only in one direction. Continue in this direction until all requests in this direction have been satisfied, then go the opposite direction.

In the scan algorithm, the head moves all theway to the first (or last) track before it changesdirection.

Page 16: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

16

Track

10

20

30

40

Steps50 100

While at track 15, assume some random set of read requestsTrack 4, 40, 11, 35, 7 and 16. Head is moving towards highernumbered tracks.

Scan-Look

Head Path Tracks Traveled

Page 17: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

17

Track

10

20

30

40

Steps50 100

While at track 15, assume some random set of read requestsTrack 4, 40, 11, 35, 7 and 16. Head is moving towards highernumbered tracks.

Scan-Look

Head Path Tracks Traveled

15 – 16 116 – 35 1935 – 40 540 – 11 2911 – 7 47 – 4 3

61 tracks

Page 18: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

18

Which algorithm would you choose if you wereimplementing an operating system? Issues to consider when selecting a disk scheduling algorithm:

Performance is based on the number and types of requests.

What scheme is used to allocate unused disk blocks?

How and where are directories and i-nodes stored?

How does paging impact disk performance?

How does disk caching impact performance?

Page 19: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

19

Disk CacheDisk Cache

The disk cache holds a number of disk blocks in memory,usually in RAM on the disk controller.

When an I/O request is made for a particular block, the disk cache is checked. If the block is in the cache, it is read. Otherwise, the required block (and often somecontiguous blocks) are read into the cache.

Page 20: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

20

Replacement StrategiesReplacement Strategies

Least Recently Used

replace the block that has been in the cache the longest, without being referenced.

Least Frequently Used

replace the block that has been used the least

Page 21: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

21

RAIDRedundant Array of Independent Disks

• Push Performance

• Add reliability

Page 22: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

22

RAID Level 0: Striping

Logical Disk

strip 0

strip 1

strip 2

strip 3

strip 4

strip 5

strip 6

strip 7

strip 8

strip 9

strip 10

strip 11

o o o

strip 0

strip 2

strip 4

strip 6

o o o

strip 1

strip 3

strip 5

strip 7

o o o

PhysicalDrive 1

PhysicalDrive 2

Disk ManagementSoftware

A Stripe

Page 23: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

23

RAID Level 1: Mirroring

Logical Disk

strip 0

strip 1

strip 2

strip 3

strip 4

strip 5

strip 6

strip 7

strip 8

strip 9

strip 10

strip 11

o o o

strip 0

strip 2

strip 4

strip 6

o o o

strip 1

strip 3

strip 5

strip 7

o o o

PhysicalDrive 1

PhysicalDrive 2

Disk ManagementSoftware

strip 0

strip 2

strip 4

strip 6

o o o

strip 1

strip 3

strip 5

strip 7

o o o

strip 0

strip 2

strip 4

strip 6

o o o

strip 1

strip 3

strip 5

strip 7

o o o

PhysicalDrive 3

PhysicalDrive 4

strip 0

strip 2

strip 4

strip 6

o o o

strip 1

strip 3

strip 5

strip 7

o o o

High Reliability

Duplicate writes to drive 1 and drive 2 on these disks

Page 24: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

24

RAID Level 3: Parity

Logical Disk

strip 0

strip 1

strip 2

strip 3

strip 4

strip 5

strip 6

strip 7

strip 8

strip 9

strip 10

strip 11

o o o

strip 0

strip 2

strip 4

strip 6

o o o

strip 1

strip 3

strip 5

strip 7

o o o

PhysicalDrive 1

PhysicalDrive 2

Disk ManagementSoftware

strip 0

strip 3

strip 6

strip 9

o o o

strip 1

strip 4

strip 7

strip 10

o o o

strip 0

strip 2

strip 4

strip 6

o o o

strip 1

strip 3

strip 5

strip 7

o o o

PhysicalDrive 3

PhysicalDrive 4

strip 2

strip 5

strip 8

strip 11

o o o

para

parb

parc

pard

o o o

High Throughput

parity

Page 25: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

25

Thinking about whatyou have learned

Page 26: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

26

Suppose that 3 processes, p1, p2, and p3 are attempting to concurrently use a machine with interrupt driven I/O. Assuming that no two processes can be using the cpu or the physical device at the same time, what is the minimum amount of time required to execute the three processes, given the following (ignore context switches):

Process Time compute Time device

1 10 50 2 30 10 3 15 35

Page 27: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

27

Process Time compute Time device

1 10 50 2 30 10 3 15 35

0 10 20 30 40 50 60 70 80 90 100 110 120 130

P1p2

p3

105

Page 28: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

28

Consider the case where the device controller is double buffering I/O.That is, while the process is reading a character from one buffer, the device is writing to the second.

Process

DeviceController

What is the effect on the running time of the process if the process is I/O bound and requests characters faster than the device can provide them?

The process reads from buffer A.It tries to read from buffer B, but the device is still reading. The process blocks until the data has been storedin buffer B. The process wakes up and reads the data, then tries to read Buffer A.Double buffering has not helped performance.

BA

Page 29: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

29

Consider the case where the device controller is double buffering I/O.That is, while the process is reading a character from one buffer, the device is writing to the second. Process

DeviceController

What is the effect on the running time of the process if the process is Compute bound and requests characters much slower than the device can provide them?

The process reads from buffer A.It then computes for a long time.Meanwhile, buffer B is filled. When The process asks for the data it isalready there. The process does nothave to wait and performance improves.

A B

Page 30: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

30

Suppose that the read/write head is at track is at track 97, moving toward the highest numbered track on the disk, track 199. The disk request queue contains read/write requests for blocks on tracks 84, 155, 103, 96, and 197, respectively.

How many tracks must the head step across usinga FCFS strategy?

Page 31: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

31

Suppose that the read/write head is at track is at track 97, moving toward the highest numbered track on the disk, track 199. The disk request queue contains read/write requests for blocks on tracks 84, 155, 103, 96, and 197, respectively.

How many tracks must the head step across usinga FCFS strategy?

Track

50

100

150

199

Steps100 200

97 to 84 13 steps84 to 155 71 steps155 to 103 52 steps103 to 96 7 steps96 to 197 101 steps

244 steps

Page 32: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

32

Suppose that the read/write head is at track is at track 97, moving toward the highest numbered track on the disk, track 199. The disk request queue contains read/write requests for blocks on tracks 84, 155, 103, 96, and 197, respectively.

How many tracks must the head step across usingan elevator strategy?

Page 33: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

33

Suppose that the read/write head is at track is at track 97, moving toward the highest numbered track on the disk, track 199. The disk request queue contains read/write requests for blocks on tracks 84, 155, 103, 96, and 197, respectively.

How many tracks must the head step across usingan elevator strategy?

Track

50

100

150

199

Steps100 200

97 to 103 6 steps103 to 155 52 steps155 to 197 42 steps197 to 199 2 steps199 to 96 103 steps96 to 84 12 steps

217steps

Page 34: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

34

In our class discussion on directories it was suggestedthat directory entries are stored as a linear list. Whatis the big disadvantage of storing directory entriesthis way, and how could you address this problem?

Consider what happens when look up a file …The directory must be searched in a linear way.

Page 35: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

35

Which file allocation scheme discussed in class gives thebest performance? What are some of the concerns with this approach?

Contiguous allocation schemes gives the best performance.Two big problems are: * Finding space for a new file (it must all fit in contiguous blocks) * Allocating space when we don’t know how big the file will be, or handling files that grow over time.

Page 36: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

36

What is the difference between internal andexternal fragmentation?

Internal fragmentation occurs when only a portion of afile block is used by a file.

External fragmentation occurs when the free space on a diskdoes not contain enough space to hold a file.

Page 37: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

37

Linked allocation of disk blocks solves many of theproblems of contiguous allocation, but it does notwork very well for random access files. Why not?

To access a random block on disk, you must walkThrough the entire list up to the block you need.

Page 38: 1 Disk Scheduling Because Disk I/O is so important, it is worth our time to Investigate some of the issues involved in disk I/O. One of the biggest issues

38

Linked allocation of disk blocks has a reliabilityproblem. What is it?

If a link breaks for any reason, the disk blocks afterThe broken link are inaccessible.