The contents of this chapter include all of the following: Discuss the principal requirements for memory management, understand the reason for memory partitioning and explain the various techniques that are used, understand and explain the concept of paging,...
CSC 322 Operating Systems Concepts Lecture - 26: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems e, (c) 2008 Prentice-Hall, Inc (Chapter5) Silberschatz, Galvin and Gagne 2002, Operating System Concepts, Ahmed Mumtaz Mustehsan, GM-IT, Chapter Input/ Output Hardware Disk (Magnetic / Optical ) Lecture-24 Ahmed Mumtaz Disks • Called Magnetic (hard) disk • Reads and writes are equally fast • Good for storing file systems • • Disk arrays are used for reliable storage (RAID) Optical disks (CD-ROM, CD-Recordable, DVD) used for program distribution Floppy vs hard disk (20 years apart) • Seek time is 7x better, transfer rate is 1300 x better, capacity is 50,000 x better Disks-more stuff • • • • Some disks have microcontrollers which bad block re-mapping, track caching Some disk controllers are capable of doing more then one seek at a time, i.e they can read on one disk while writing on another Real disk geometry is different from geometry used by driver, since controller has to re-map request for (cylinder, head, sector) onto actual disk Disks are divided into zones, with fewer sector at the inner side, gradually progressing to more on the outer side Disk Zones (a) Physical geometry of a disk with two zones (b) A possible virtual geometry for this disk Redundant Array of Inexpensive Disks (RAID) • Parallel I/O to improve performance and reliability vs SLED, Single Large Expensive Disk • • • • RAID; A bunch of disks which appear like a single disk to the OS SCSI disks often used-cheap, disks per controller SCSI is set of standards to connect CPU to peripherals Different architectures-level through level RAID Integrated Redundanc y • • Performanc e Redundant Array of Independent Disks Consists of seven levels, zero through six RAID Level • Not a true RAID because it does not include redundancy to improve performance or provide data protection • User and system data are distributed across all of the disks in the array • Logical disk is divided into strips RAID Level • • • • Redundancy is achieved by the simple expedient of duplicating all the data There is no “write penalty” When a drive fails the data may still be accessed from the second drive Principal disadvantage is the cost First-In, First-Out (FIFO) • • • Processes in sequential order Fair to all processes Approximates random scheduling in performance if there are many processes competing for the disk Priority (PRI) • • • • • • Control of the scheduling is outside the control of disk management software Goal is not to optimize disk utilization but to meet other objectives Short batch jobs and interactive jobs are given higher priority Provides good interactive response time Longer jobs may have to wait an excessively long time A poor policy for database systems Shortest Service Time First (SSTF) • • Select the disk I/O request that requires the least movement of the disk arm from its current position Always choose the minimum seek time SSF (Shortest Seek Time First) • • • While head is on cylinder 11, requests for 1,36,16,34,9,12 come in FCFS would result in (10,35,20,18,25,3) 111 cylinders SSF would require 1,3,7,15,33,2 movements for a total of 61 cylinders SCAN- Elevator algorithm • • • • It is a greedy algorithm-the head could get stuck in one part of the disk if the usage was heavy Elevator-keep going in one direction until there are no requests in that direction, then reverse direction Real elevators sometimes use this algorithm Variation on a theme-first go one way, then go the other SCAN (Elevator algorithm) • • • Also known as the Elevator algorithm Arm moves in one direction only • satisfies all outstanding requests until it reaches the last track in that direction then the direction is reversed Favors jobs whose requests are for tracks nearest to both innermost and outermost tracks C-SCAN (Circular SCAN) Restricts scanning to one direction only • • When the last track has been visited in one direction, the arm is returned to the opposite end of the disk and the scan begins again The Elevator • Uses 60 cylinders, usually slightly worst then SSF, but better/fair in service N-Step-SCAN • • • • Segments the disk request queue into subqueues of length N Sub-queues are processed one at a time, using SCAN While a queue is being processed new requests must be added to some other queue If fewer than N requests are available at the end of a scan, all of them are processed with the next scan FSCAN • • • • Uses two sub-queues When a scan begins, all of the requests are in one of the queues, with the other empty During scan, all new requests are put into the other queue Service of new requests is deferred until all of the old requests have been processed Disk Controller Cache • Disk controllers have their own cache • Cache is separate from the OS cache • • OS caches blocks independently of where they are located on the disk Controller caches blocks which were easy to read but which were not necessarily requested Disk Cache • • • • Cache memory is used to apply to a memory that is smaller and faster than main memory and that is interposed between main memory and the processor Reduces average memory access time by exploiting the principle of locality Disk cache is a buffer in main memory for disk sectors Bad Sectors-the controller approach • • • • Manufacturing defect-that which was written does not correspond to that which is read (back) Controller or OS deals with bad sectors If controller deals with them the factory provides a list of bad blocks and controller remaps good spares in place of bad blocks Substitution can be done when the disk is in use-controller “notices” that block is bad and substitutes Error Handling (a) A disk track with a bad sector (b) Substituting a spare for the bad sector (c) Shifting all the sectors to bypass the bad one Bad Sectors-the OS approach • • Gets messy if the OS has to it OS needs lots of information-which blocks are bad or has to test blocks itself ... kernel in the file system OS kernel is loaded and executed Disk Performance Parameters The actual details of disk I/O operation depend on the: • computer system • operating system • nature of... (CD-ROM, CD-Recordable, DVD) used for program distribution Floppy vs hard disk (20 years apart) • Seek time is 7x better, transfer rate is 1300 x better, capacity is 50,000 x better Disks-more... Hardware Disk (Magnetic / Optical ) Lecture- 24 Ahmed Mumtaz Disks • Called Magnetic (hard) disk • Reads and writes are equally fast • Good for storing file systems • • Disk arrays are used for