12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Sec. 8.2 Disk Drives 285the information flow at a constant rate along the spiral, the drive must speed up therate of disk spin as the I/O head moves <strong>to</strong>ward the center of the disk. This makesfor a more complicated <strong>and</strong> slower mechanism.Three separate steps take place when reading a particular byte or series of bytesof data from a hard disk. First, the I/O head moves so that it is positioned over thetrack containing the data. This movement is called a seek. Second, the sec<strong>to</strong>rcontaining the data rotates <strong>to</strong> come under the head. When in use the disk is alwaysspinning. At the time of this writing, typical disk spin rates are 7200 rotations perminute (rpm). The time spent waiting for the desired sec<strong>to</strong>r <strong>to</strong> come under theI/O head is called rotational delay or rotational latency. The third step is theactual transfer (i.e., reading or writing) of data. It takes relatively little time <strong>to</strong>read information once the first byte is positioned under the I/O head, simply theamount of time required for it all <strong>to</strong> move under the head. In fact, disk drives aredesigned not <strong>to</strong> read one byte of data, but rather <strong>to</strong> read an entire sec<strong>to</strong>r of data ateach request. Thus, a sec<strong>to</strong>r is the minimum amount of data that can be read orwritten at one time.In general, it is desirable <strong>to</strong> keep all sec<strong>to</strong>rs for a file <strong>to</strong>gether on as few tracksas possible. This desire stems from two assumptions:1. Seek time is slow (it is typically the most expensive part of an I/O operation),<strong>and</strong>2. If one sec<strong>to</strong>r of the file is read, the next sec<strong>to</strong>r will probably soon be read.Assumption (2) is called locality of reference, a concept that comes up frequentlyin computer applications.Contiguous sec<strong>to</strong>rs are often grouped <strong>to</strong> form a cluster. A cluster is the smallestunit of allocation for a file, so all files are a multiple of the cluster size. The clustersize is determined by the operating system. The file manager keeps track of whichclusters make up each file.In Microsoft Windows systems, there is a designated portion of the disk calledthe File Allocation Table, which s<strong>to</strong>res information about which sec<strong>to</strong>rs belong<strong>to</strong> which file. In contrast, UNIX does not use clusters. The smallest unit of fileallocation <strong>and</strong> the smallest unit that can be read/written is a sec<strong>to</strong>r, which in UNIXterminology is called a block. UNIX maintains information about file organizationin certain disk blocks called i-nodes.A group of physically contiguous clusters from the same file is called an extent.Ideally, all clusters making up a file will be contiguous on the disk (i.e., the file willconsist of one extent), so as <strong>to</strong> minimize seek time required <strong>to</strong> access differentportions of the file. If the disk is nearly full when a file is created, there might notbe an extent available that is large enough <strong>to</strong> hold the new file. Furthermore, if a file

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!