Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Disk Management operating systems. 2 Goals of I/O Software Provide a common, abstract view of all devices to the application programmer (open, read,

Similar presentations


Presentation on theme: "1 Disk Management operating systems. 2 Goals of I/O Software Provide a common, abstract view of all devices to the application programmer (open, read,"— Presentation transcript:

1 1 Disk Management operating systems

2 2 Goals of I/O Software Provide a common, abstract view of all devices to the application programmer (open, read, write) Provide as much overlap as possible between the operation of I/O devices and the CPU. Provide a common, abstract view of all devices to the application programmer (open, read, write) Provide as much overlap as possible between the operation of I/O devices and the CPU. operating systems

3 3 I/O – Processor Overlap Application programmers expect serial execution semantics read (device, %d, x); y = f(x); We expect that this statement will complete before the assignment is executed. To accomplish this, the OS blocks the process until the I/O operation completes. operating systems

4 4 User Process Device Independent Layer Device Dependent Layer Interrupt Handler Device Controller data status command read(device, %D, x); y = f(x); … x 5 READ CPU 5 12 Without Blocking! The read is issued.The read has not Completed … but the process continues to execute. The read completes and the value of x is updated. operating systems

5 5 In a multi-programming environment, another application could use the cpu while the first application waits for the I/O to complete. app1 app2 I/O controller Request I/O operation I/O Complete operating systems app2 done

6 6 PerformancePerformance Thread execution time can be broken into: Time compute The time the thread spends doing computations Time device The time spent on I/O operations Time overhead The time spent determining if I/O is complete So, Time total = Time compute + Time device + Time overhead operating systems

7 7 PerformancePerformance Time total = Time compute + Time device + Time overhead Time overhead = The period of time between the point where the device completes the operation and the point where the polling loop determines that the operation is complete. This is generally just a few instruction times. operating systems When the device driver polls Note that when the device driver polls, no other process can use the cpu. Polling consumes the cpu.

8 8 Are you done yet?

9 9 PerformancePerformance Time total = Time compute + Time device + Time overhead When the device driver uses interrupts Time overhead = Time handler + Time ready Time handler is the time spent in the interrupt handler Time ready is the time the process waits for the cpu after it has completed its I/O, while another process uses the CPU. operating systems When the device driver uses interrupts

10 10 process I/O controller For simplicitys sake assume processes of the following form: Each process computes for a long while and then writes its results to a file. We will ignore the time taken to do a context switch. Time compute Time device Time compute operating systems Request an I/O operation

11 11 Proc 1 Polling Case Time compute Time device Time compute Time overhead Time compute Time device Time compute Time overhead Proc 2 operating systems In the polling case, the process starts the I/O operation, and then continually loops, asking the device if it is done. Proc1 polls Proc2 polls

12 12 Proc 1 Interrupt Case Time compute Time device Time compute Time overhead Time device Proc 2 Time compute operating systems In the interrupt case, the process starts the I/O operation, and then blocks. When the I/O is done, the os will get an interrupt. Time interrupt handler

13 13 Which gives better system throughput? * Polling * Interrupts Which gives better application performance? * Polling * Interrupts If you were developing an operating system, would you choose interrupts or polling?

14 14 Buffering Issues User space Kernel Read from the disk Into user memory Assume that you are using interrupts… What problems Exist in this situation? operating systems

15 15 Buffering Issues User space Kernel Read from the disk Into user memory Assume that you are using interrupts… What problems Exist in this situation? operating systems The process cannot be completely swapped out of memory. At least the page containing the addresses into which the data is being written must remain in real memory.

16 16 Buffering Issues User space Kernel Read from the disk into kernel buffer. When the buffer is full, transfer to memory in user space. operating systems

17 17 Buffering Issues User space Kernel We can now swap the user processor out While the I/O completes. What problems Exist in this situation? 1. The O/S has to carefully keep track of the assignment of system buffers to user processes. 2. There is a performance issue when the user process is not in memory and the O/S is ready to transfer its data to the user process. Also, the device must wait while data is being transferred. 3. The swapping logic is complicated when the swapping operation uses the same disk drive for paging that the data is being read from. operating systems

18 18 Buffering Issues User space Kernel Some of the performance issues can be addressed by double buffering. While one buffer is being transferred to the user process, the device is reading data into a second buffer. operating systems

19 19 Networking may involve many copies operating systems

20 20 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 is disk performance. operating systems

21 21 seek time is the time required for the read head to move to the track containing the data to be read.

22 22 rotational delay or latency, is the time required for the sector to move under the read head.

23 23 Performance Parameters Wait for device Wait for Channel Device busy seek rotational delay data transfer Seek time is the time required to move the disk arm to the specified track T s = # tracks * disk constant + startup time ~ Rotational delay is the time required for the data on that track to come underneath the read heads. For a hard drive rotating at 3600 rpm, the average rotational delay will be 8.3ms. Transfer Time T t = bytes / ( rotation_speed * bytes_on_track ) (latency) operating systems

24 24 Data Organization vs. Performance Consider a file where the data is stored as compactly as possible, in this case 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 sectors16.7 ms Assuming that there is essentially no seek time on the remaining tracks, each successive track can be read in ms = 25ms. Total read time = 45ms + 7 * 25ms = 220ms = 0.22 seconds operating systems 45ms

25 25 If the data is randomly distributed across the disk: For each sector we have average seek time20 ms rotational delay8.3 ms read 1 sector0.5 ms Total time = 256 sectors * 28.8 ms/sector = 7.73 seconds 28.8 ms Random placement of data can be a problem when multiple processes are accessing the same disk. operating systems

26 26 In the previous example, the biggest factor on performance is ? Seek time! To improve performance, we need to reduce the average seek time. operating systems

27 27 Queue Request … If requests are scheduled in random order, then we would expect the disk tracks to be visited in a random order. operating systems

28 28 Queue Request … If there are few processes competing for the drive, 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. operating systems First-come, First-served Scheduling

29 29 Track Steps to 411 steps 4 to 4036 steps 40 to 1129 steps 11 to 3524 steps 35 to 728 steps 7 to 14 7 steps 135 steps While at track 15, assume some random set of read requests -- tracks 4, 40, 11, 35, 7 and 14 Head PathTracks Traveled operating systems

30 30 Queue Request … Shortest Seek Time First Always select the request that requires the shortest seek time from the current position. operating systems

31 31 Track Steps While at track 15, assume some random set of read requests -- tracks 4, 40, 11, 35, 7 and 14 Shortest Seek Time First Problem? In a heavily loaded system, incoming requests with a shorter seek time will constantly push requests with long seek times to the end of the queue. This results in what is called Starvation. Head PathTracks Traveled operating systems

32 32 Queue 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 have been satisfied, then go the opposite direction. operating systems In the scan algorithm, the head moves all the way to the first (or last) track with a request before it changes direction.

33 33 Track Steps While at track 15, assume some random set of read requests Track 4, 40, 11, 35, 7 and 14. Head is moving towards higher numbered tracks. Scan-Look Head Path Tracks Traveled operating systems

34 34 Which algorithm would you choose if you were implementing 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?

35 35 Disk Cache The disk cache holds a number of disk sectors in memory. When an I/O request is made for a particular sector, the disk cache is checked. If the sector is in the cache, it is read. Otherwise, the sector is read into the cache. operating systems

36 36 Replacement Strategies Least Recently Used replace the sector that has been in the cache the longest, without being referenced. Least Frequently Used replace the sector that has been used the least operating systems

37 37 RAID Redundant Array of Independent Disks Push Performance Add reliability

38 38 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 Physical Drive 1 Physical Drive 2 Disk Management Software A Stripe operating systems

39 39 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 Physical Drive 1 Physical Drive 2 Disk Management Software 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 Physical Drive 3 Physical Drive 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 operating systems

40 40 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 Physical Drive 1 Physical Drive 2 Disk Management Software 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 Physical Drive 3 Physical Drive 4 strip 2 strip 5 strip 8 strip 11 o o o par a par b par c par d o o o High Throughput operating systems parity

41 41 Thinking About What You Have Learned

42 42 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): ProcessTime compute Time device operating systems

43 43 ProcessTime compute Time device P1 p2 p3 105

44 44 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 Device Controller 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 stored in buffer B. The process wakes up and reads the data, then tries to read Buffer A. Double buffering has not helped performance. B A

45 45 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 Device Controller 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 is already there. The process does not have to wait and performance improves. A B

46 46 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 using a FCFS strategy?

47 47 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 using a FCFS strategy? Track Steps to 8413 steps 84 to steps 155 to steps 103 to 967 steps 96 to steps 244 steps

48 48 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 using an elevator strategy?

49 49 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 using an elevator strategy? Track Steps to 1036 steps 103 to steps 155 to steps 197 to 1992 steps 199 to steps 96 to 8412 steps 217steps

50 50 In our class discussion on directories it was suggested that directory entries are stored as a linear list. What is the big disadvantage of storing directory entries this way, and how could you address this problems? Consider what happens when look up a file … The directory must be searched in a linear way.

51 51 Which file allocation scheme discussed in class gives the best 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 dont know how big the file will be, or handling files that grow over time.

52 52 What is the difference between internal and external fragmentation? Internal fragmentation occurs when only a portion of a File block is used by a file. External fragmentation occurs when the free space on a disk does not contain enough space to hold a file.

53 53 Linked allocation of disk blocks solves many of the problems of contiguous allocation, but it does not work very well for random access files. Why not? To access a random block on disk, you must walk Through the entire list up to the block you need.

54 54 Linked allocation of disk blocks has a reliability problem. What is it? If a link breaks for any reason, the disk blocks after The broken link are inaccessible.


Download ppt "1 Disk Management operating systems. 2 Goals of I/O Software Provide a common, abstract view of all devices to the application programmer (open, read,"

Similar presentations


Ads by Google