11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

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

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

268 Chap. 8 File Processing <strong>and</strong> External SortingThis requires the ability to guess accur<strong>at</strong>ely wh<strong>at</strong> inform<strong>at</strong>ion will be needed l<strong>at</strong>er<strong>and</strong> store it in primary memory now. This is referred to as caching.8.2 Disk DrivesA Java programmer views a r<strong>and</strong>om access file stored on disk as a contiguousseries of bytes, with those bytes possibly combining to form d<strong>at</strong>a records. Thisis called the logical file. The physical file actually stored on disk is usually nota contiguous series of bytes. It could well be in pieces spread all over the disk.The file manager, a part of the oper<strong>at</strong>ing system, is responsible for taking requestsfor d<strong>at</strong>a from a logical file <strong>and</strong> mapping those requests to the physical loc<strong>at</strong>ionof the d<strong>at</strong>a on disk. Likewise, when writing to a particular logical byte positionwith respect to the beginning of the file, this position must be converted by thefile manager into the corresponding physical loc<strong>at</strong>ion on the disk. To gain someappreci<strong>at</strong>ion for the the approxim<strong>at</strong>e time costs for these oper<strong>at</strong>ions, you need tounderst<strong>and</strong> the physical structure <strong>and</strong> basic workings of a disk drive.Disk drives are often referred to as direct access storage devices. This meansth<strong>at</strong> it takes roughly equal time to access any record in the file. This is in contrastto sequential access storage devices such as tape drives, which require the tapereader to process d<strong>at</strong>a from the beginning of the tape until the desired position hasbeen reached. As you will see, the disk drive is only approxim<strong>at</strong>ely direct access:At any given time, some records are more quickly accessible than others.8.2.1 Disk Drive ArchitectureA hard disk drive is composed of one or more round pl<strong>at</strong>ters, stacked one on top ofanother <strong>and</strong> <strong>at</strong>tached to a central spindle. Pl<strong>at</strong>ters spin continuously <strong>at</strong> a constantr<strong>at</strong>e. Each usable surface of each pl<strong>at</strong>ter is assigned a read/write head or I/Ohead through which d<strong>at</strong>a are read or written, somewh<strong>at</strong> like the arrangement ofa phonograph player’s arm “reading” sound from a phonograph record. Unlike aphonograph needle, the disk read/write head does not actually touch the surface ofa hard disk. Instead, it remains slightly above the surface, <strong>and</strong> any contact duringnormal oper<strong>at</strong>ion would damage the disk. This distance is very small, much smallerthan the height of a dust particle. It can be likened to a 5000-kilometer airplane tripacross the United St<strong>at</strong>es, with the plane flying <strong>at</strong> a height of one meter!A hard disk drive typically has several pl<strong>at</strong>ters <strong>and</strong> several read/write heads, asshown in Figure 8.2(a). Each head is <strong>at</strong>tached to an arm, which connects to theboom. 2 The boom moves all of the heads in or out together. When the heads arein some position over the pl<strong>at</strong>ters, there are d<strong>at</strong>a on each pl<strong>at</strong>ter directly accessible2 This arrangement, while typical, is not necessarily true for all disk drives. Nearly everythingsaid here about the physical arrangement of disk drives represents a typical engineering compromise,not a fundamental design principle. There are many ways to design disk drives, <strong>and</strong> the engineering

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

Saved successfully!

Ooh no, something went wrong!