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

Slides:



Advertisements
Similar presentations
Disks Disk Hardware (1) Disk parameters for the original IBM PC floppy disk and a Western Digital WD hard disk.
Advertisements

I/O Management and Disk Scheduling
Chapter 5 Input/Output 5.4 Disks
- Dr. Kalpakis CMSC Dr. Kalpakis 1 Outline In implementing DBMS we need to answer How should the system store and manage very large amounts of data?
CS 6560: Operating Systems Design
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Disks and RAID.
CSE506: Operating Systems Disk Scheduling. CSE506: Operating Systems Key to Disk Performance Don’t access the disk – Whenever possible Cache contents.
RAID and Other Disk Details
Operating Systems Input/Output Devices (Ch , 12.7; , 13.7)
Other Disk Details. 2 Disk Formatting After manufacturing disk has no information –Is stack of platters coated with magnetizable metal oxide Before use,
CS 333 Introduction to Operating Systems Class 16 – Secondary Storage Management Jonathan Walpole Computer Science Portland State University.
Lecture 17 I/O Optimization. Disk Organization Tracks: concentric rings around disk surface Sectors: arc of track, minimum unit of transfer Cylinder:
Disk Drivers May 10, 2000 Instructor: Gary Kimura.
Fig 5-5 Interrupts Handling
1 Storage Hierarchy Cache Main Memory Virtual Memory File System Tertiary Storage Programs DBMS Capacity & Cost Secondary Storage.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output – 5 Disks CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
CS 333 Introduction to Operating Systems Class 16 – Secondary Storage Management Jonathan Walpole Computer Science Portland State University.
Avishai Wool lecture Introduction to Systems Programming Lecture 9 Input-Output Devices.
Secondary Storage CSCI 444/544 Operating Systems Fall 2008.
04/21/2004CSCI 315 Operating Systems Design1 Disk Scheduling.
1 Input/Output Chapter 3 TOPICS Principles of I/O hardware Principles of I/O software I/O software layers Disks Clocks Reference: Operating Systems Design.
Operating Systems Input/Output Devices (Ch 5: )
Secondary Storage Management Hank Levy. 8/7/20152 Secondary Storage • Secondary Storage is usually: –anything outside of “primary memory” –storage that.
Introduction to Database Systems 1 The Storage Hierarchy and Magnetic Disks Storage Technology: Topic 1.
12.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 12: Mass-Storage Systems.
Disk and I/O Management
Hard Drive / Hard Disk Functions of hard disk
CS4432: Database Systems II Data Storage (Better Block Organization) 1.
CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID.
1 Recitation 8 Disk & File System. 2 Disk Scheduling Disks are at least four orders of magnitude slower than main memory –The performance of disk I/O.
Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.
Lecture 9 of Advanced Databases Storage and File Structure (Part II) Instructor: Mr.Ahmed Al Astal.
CSC 322 Operating Systems Concepts Lecture - 26: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Disk Structure Disk drives are addressed as large one- dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer.
Sistem Operasi IKH311 Masukan Luaran (Input/Output)
PC Maintenance: Preparing for A+ Certification Chapter 10: Introduction to Disk Storage.
Disks and Storage Systems
1Fall 2008, Chapter 12 Disk Hardware Arm can move in and out Read / write head can access a ring of data as the disk rotates Disk consists of one or more.
CS 6502 Operating Systems Dr. J.. Garrido Device Management (Lecture 7b) CS5002 Operating Systems Dr. Jose M. Garrido.
CE Operating Systems Lecture 20 Disk I/O. Overview of lecture In this lecture we will look at: Disk Structure Disk Scheduling Disk Management Swap-Space.
I/O Management and Disk Structure Introduction to Operating Systems: Module 14.
Disks Chapter 5 Thursday, April 5, Today’s Schedule Input/Output – Disks (Chapter 5.4)  Magnetic vs. Optical Disks  RAID levels and functions.
Lecture 3 Page 1 CS 111 Online Disk Drives An especially important and complex form of I/O device Still the primary method of providing stable storage.
Disk formatting Magnetic disks come in various sizes and so each use different disk drives. Different computers have different ways of organizing data.
Auxiliary Memory Magnetic Disk:
Chapter 5 Input/Output 5.1 Principles of I/O hardware
Disk Basics CS Introduction to Operating Systems.
Disk storage systems Question#1 (True/False) A track is divided into multiple units called sectors.
CS399 New Beginnings Jonathan Walpole. Disk Technology & Secondary Storage Management.
Part IV I/O System Chapter 12: Mass Storage Structure.
Disks. ●Circular-shaped storage medium ●Two main types: Magnetic and Optical ●Random access to memory ●The hardware must be controlled by driver software.
1 Components of the Virtual Memory System  Arrows indicate what happens on a lw virtual address data physical address TLB page table memory cache disk.
Magnetic Disks Have cylinders, sectors platters, tracks, heads virtual and real disk blocks (x cylinders, y heads, z sectors per track) Relatively slow,
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems DISK I/0.
Multiple Platters.
Disks and RAID.
Visit for more Learning Resources
I/O Resource Management: Software
Operating System I/O System Monday, August 11, 2008.
Disks.
CS510 Operating System Foundations
Overview Continuation from Monday (File system implementation)
Jonathan Walpole Computer Science Portland State University
Disks and scheduling algorithms
Secondary Storage Management Brian Bershad
Secondary Storage Management Hank Levy
CS333 Intro to Operating Systems
CSE451 File System Introduction and Disk Drivers Autumn 2002
Hard disk basics Prof:R.CHARLES SILVESTER JOE Departmet of Electronics St.Joseph’s College,Trichy.
Disks Magnetic (hard) Disk arrays are used for reliable storage (RAID)
Presentation transcript:

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

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

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

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

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

Disk Formatting

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

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

Cylinder Skew

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

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

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

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 bytes on the track If a 10K RPM diver has 300 sectors per track of 512 bytes, it takes 6 msec to read the 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!

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

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

Interleaving

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

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

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

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

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

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

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

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

Shortest Seek First

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

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

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

Elevator Algorithm

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

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

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

Error Handling Swap with spare Re-write preambles

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

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

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

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

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

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

Stable Storage