Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems COMP 4850/CISG 5550 Disks, Part II Dr. James Money.

Similar presentations


Presentation on theme: "Operating Systems COMP 4850/CISG 5550 Disks, Part II Dr. James Money."— Presentation transcript:

1 Operating Systems COMP 4850/CISG 5550 Disks, Part II Dr. James Money

2 Disk Formatting What does the hard disk consist of? What does the hard disk consist of? –Stack of platters –Each platter is coated with a thin layer of magnetizable metal oxide –Read/Write heads –Associated motors

3 Disk Formatting Before use, the disk must have a low-level format, which is done by software Before use, the disk must have a low-level format, which is done by software –There are a series of concentric tracks –Each track has sectors –There is a gap between consecutive sectors

4 Disk Formatting The format of a sector consists of The format of a sector consists of –Preamble – contains a particular bit pattern so the hardware recognizes the start of a sector –Data – The size is determined by the low-level format used. Most of the time it is 512 bytes

5 Disk Formatting –ECC – Error correction code, which is used to recover from read errors. This size varies on the controller and generally gives higher reliability for bigger ECCs. Many times it is 16 bytes –Spare sectors – used to replace bad sectors due to a manufacturing defect

6 Disk Formatting

7 Cylinder Skew Sector 0 on each track is offset from the previous track Sector 0 on each track is offset from the previous track This is called cylinder skew This is called cylinder skew Used to improve performance Used to improve performance This allows one continuous read from track to track This allows one continuous read from track to track

8 Cylinder Skew Consider a disk with 16 sectors per track Consider a disk with 16 sectors per track Assume that we read 18 sectors starting a sector 0 Assume that we read 18 sectors starting a sector 0 Once we reach sector 17, we need to go to the next track Once we reach sector 17, we need to go to the next track However, if they are aligned, we have to rotate around once before reading However, if they are aligned, we have to rotate around once before reading Cylinder skew eliminates this Cylinder skew eliminates this

9 Cylinder Skew

10 The amount of skew depends on the drive geometry The amount of skew depends on the drive geometry For example, a 10k RPM drive rotates in 6 msecs For example, a 10k RPM drive rotates in 6 msecs If the track has 300 sectors, each sector takes 20μsecs If the track has 300 sectors, each sector takes 20μsecs If track-to-track seek takes 800 μsecs, then 40 sectors pass by If track-to-track seek takes 800 μsecs, then 40 sectors pass by The skew should be 40 sectors The skew should be 40 sectors There also a head skew, but this is much smaller for switching heads There also a head skew, but this is much smaller for switching heads

11 Disk Capacity When low-level formatting finishes, the disk capacity has been reduced When low-level formatting finishes, the disk capacity has been reduced Many times, this amount is 20% less than the original value Many times, this amount is 20% less than the original value Spare sectors are not counted in original capacity Spare sectors are not counted in original capacity

12 Disk Capacity There is much confusion in this area There is much confusion in this area Many times, manufacturers report unformatted capacity Many times, manufacturers report unformatted capacity For example, consider a driver with 20 x 10 9 bytes unformatted For example, consider a driver with 20 x 10 9 bytes unformatted This may be sold as 20GB disk This may be sold as 20GB disk But after formatting, this is 2 34 ≈ 17.2 x 10 9 bytes But after formatting, this is 2 34 ≈ 17.2 x 10 9 bytes In addition, the OS may say it is 16GB due to base 2 versus base 10 In addition, the OS may say it is 16GB due to base 2 versus base 10

13 Performance Formatting also affects performance Formatting also affects performance If a 10K RPM diver has 300 sectors per track of 512 bytes, it takes 6 msec to read the 153600 bytes on the track If a 10K RPM diver has 300 sectors per track of 512 bytes, it takes 6 msec to read the 153600 bytes on the track The data rate is 25,600,000 bytes/sec or 24.4 MB/sec. The data rate is 25,600,000 bytes/sec or 24.4 MB/sec. Not possible to get faster than this! Not possible to get faster than this!

14 Performance Reading continuous also affects the performance Reading continuous also affects the performance If the controller has a one sector buffer and is reading two consecutive sectors If the controller has a one sector buffer and is reading two consecutive sectors This first is read, but cannot read the second since it has to be copied to main memory This first is read, but cannot read the second since it has to be copied to main memory The track has to spin around an extra time The track has to spin around an extra time

15 Performance We can eliminate this with sector interleaving We can eliminate this with sector interleaving There are three types There are three types –No interleave –Single Interleave –Double Interleave – needed if copying is slow Many controllers read entire track into memory Many controllers read entire track into memory

16 Interleaving

17 Partitioning After the low-level format, the disk is partitioned After the low-level format, the disk is partitioned Each partition is like a separate disk Each partition is like a separate disk Sector 0 usually contains the master boot record Sector 0 usually contains the master boot record The MBR contains boot code with the partition table at the end The MBR contains boot code with the partition table at the end Partition table has starting sector and size Partition table has starting sector and size

18 High-Level Format The final step in disk preparation is the high-level format The final step in disk preparation is the high-level format This is performed on each partition This is performed on each partition It sets up the boot block, free storage administration and the file system It sets up the boot block, free storage administration and the file system It also stores the type of file system in the partition table It also stores the type of file system in the partition table

19 Disk Arm Scheduling Algorithms We now consider some of the issues associated with the disk driver We now consider some of the issues associated with the disk driver The time required to read/write a block is determined by The time required to read/write a block is determined by –Seek time – time to move arm to proper cylinder –Rotational Delay – time for proper sector to rotate under the head –Actual data transfer time

20 Disk Arm Scheduling Algorithms Seek time tends to dominate the other two times Seek time tends to dominate the other two times We wish to reduce the mean seek time to improve our performance We wish to reduce the mean seek time to improve our performance

21 Disk Arm Scheduling Algorithms If the disk driver accepts requests one at a time and carries them out in that order, then we have First-Come, First-Served If the disk driver accepts requests one at a time and carries them out in that order, then we have First-Come, First-Served We can do little to optimize seek time We can do little to optimize seek time However, many times multiple requests come in about the same time However, many times multiple requests come in about the same time Usually there is a table with the list of requests by cylinder number Usually there is a table with the list of requests by cylinder number

22 Disk Arm Scheduling Algorithms Consider a disk with 40 cylinders Consider a disk with 40 cylinders A request comes to read cylinder 11 A request comes to read cylinder 11 While the seek to cylinder 11 occurs, we get requests for cylinders 1, 36, 16, 34, 9, and 12 in that order While the seek to cylinder 11 occurs, we get requests for cylinders 1, 36, 16, 34, 9, and 12 in that order When the request for 11 is finished, it has to decide which cylinder to request next When the request for 11 is finished, it has to decide which cylinder to request next

23 First-Come First Served We could use FCFS, but this is inefficient We could use FCFS, but this is inefficient It would require arm motions of 10, 35, 20, 18, 25, and 11 for a total of 111 cylinders It would require arm motions of 10, 35, 20, 18, 25, and 11 for a total of 111 cylinders

24 Shortest Seek First A better approach is Shortest Seek First (SSF) A better approach is Shortest Seek First (SSF) The sequence would be 12, 9, 16, 1, 34, 36 The sequence would be 12, 9, 16, 1, 34, 36 The arm motions are 1,3,7,15,33,2 with a total of 61 cylinders The arm motions are 1,3,7,15,33,2 with a total of 61 cylinders

25 Shortest Seek First

26 If there is repeat incoming requests all nearby, further away requests do not get serviced If there is repeat incoming requests all nearby, further away requests do not get serviced In a heavily loaded disk, this leads to only requests in the middle of the disk being performed In a heavily loaded disk, this leads to only requests in the middle of the disk being performed

27 Elevator Algorithm Tall building have the same problem with elevators Tall building have the same problem with elevators The idea they use is to keep going in the same direction until there are no more requests The idea they use is to keep going in the same direction until there are no more requests Then the direction switches Then the direction switches This method is called the elevator algorithm This method is called the elevator algorithm

28 Elevator Algorithm Assume, up direction Assume, up direction The service order is then 12, 16, 34, 36, 9, and 1 The service order is then 12, 16, 34, 36, 9, and 1 The arm motion is 1, 4, 18, 2, 27, and 8 for a total of 60 cylinders The arm motion is 1, 4, 18, 2, 27, and 8 for a total of 60 cylinders Tends to be a little worse than SSF Tends to be a little worse than SSF The upper bound on the total motion is twice the number of cylinders The upper bound on the total motion is twice the number of cylinders

29 Elevator Algorithm

30 Error Handling Manufacturers push the limits of hardware Manufacturers push the limits of hardware Many times you see 5000 bits/mm Many times you see 5000 bits/mm This requires a fine coating on the disk This requires a fine coating on the disk We cannot manufacture a disk without defects We cannot manufacture a disk without defects Otherwise, we increase density and repeat the process Otherwise, we increase density and repeat the process

31 Error Handling This results in bad sectors This results in bad sectors How to deal with them? How to deal with them? If it is just a few bytes, the ECC can correct it If it is just a few bytes, the ECC can correct it Otherwise, we have to use one of the spare sectors and substitute it for the bad one Otherwise, we have to use one of the spare sectors and substitute it for the bad one

32 Error Handling There are two ways to do this substitution There are two ways to do this substitution –Remap the sector –Move all the sector numbers up by one This is kept track using internal tables on the disk or by rewriting the preambles with new sector numbers This is kept track using internal tables on the disk or by rewriting the preambles with new sector numbers Tradeoff with performance and re-writing preambles Tradeoff with performance and re-writing preambles

33 Error Handling Swap with spare Re-write preambles

34 Error Handling What happens after the disk is being used? What happens after the disk is being used? –We can handle the error in the OS or controller –If the controller handles it, the first approach must be used to swap sectors since there is data on the disk now

35 Error Handling If the OS handles the remapping If the OS handles the remapping –It must determine the sector does not affect any files –Remove references in the free block list –One way to keep track of these bad sectors is to have a sector file for the file system

36 Error Handling Another class of errors is seek errors Another class of errors is seek errors If the arm goes to the wrong position, you have a seek error If the arm goes to the wrong position, you have a seek error In effect, you are reading the wrong sector In effect, you are reading the wrong sector Most controllers fix this automatically Most controllers fix this automatically Floppy drives do not and just set an error bit Floppy drives do not and just set an error bit

37 Stable Storage We have seen that we can prevent some errors and correct from some others (RAID, etc) We have seen that we can prevent some errors and correct from some others (RAID, etc) However, we do not protect against writing bad data to the disks yet However, we do not protect against writing bad data to the disks yet We want to correct write the data or nothing at all We want to correct write the data or nothing at all This is called stable storage This is called stable storage

38 Stable Storage We use a pair of identical disks We use a pair of identical disks The corresponding blocks work together to form one error free block The corresponding blocks work together to form one error free block The data should be same on both blocks if the write was a success The data should be same on both blocks if the write was a success

39 Stable Storage We need three operations: We need three operations: –Stable writes – write block on first drive, retrying if needed. Then write to second drive –Stable read – read block from drive 1, retrying if needed. Unlikely blocks on both drives fail –Crash Recovery – If both blocks are the same, nothing is done. If one drive has ECC error, the good block replaces the bad one. If both blocks are good, but one is different, drive 1 replaces drive 2 data

40 Stable Storage


Download ppt "Operating Systems COMP 4850/CISG 5550 Disks, Part II Dr. James Money."

Similar presentations


Ads by Google