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.

Sec. 8.2 Disk Drives 273pl<strong>at</strong>ter contains 13,085 tracks <strong>and</strong> each track contains (after form<strong>at</strong>ting)256 sectors of 512 bytes/sector. Track-to-track seek time is 2.2 ms <strong>and</strong> averageseek time for r<strong>and</strong>om access is 9.5 ms. Assume the oper<strong>at</strong>ing systemmaintains a cluster size of 8 sectors per cluster (4KB), yielding 32 clustersper track. The disk rot<strong>at</strong>ion r<strong>at</strong>e is 5400 rpm (11.1 ms per rot<strong>at</strong>ion). Basedon this inform<strong>at</strong>ion we can estim<strong>at</strong>e the cost for various file processing oper<strong>at</strong>ions.How much time is required to read the track? On average, it will requirehalf a rot<strong>at</strong>ion to bring the first sector of the track under the I/O head, <strong>and</strong>then one complete rot<strong>at</strong>ion to read the track.How long will it take to read a file of 1MB divided into 2048 sectorsized(512 byte) records? This file will be stored in 256 clusters, becauseeach cluster holds 8 sectors. The answer to the question depends largelyon how the file is stored on the disk, th<strong>at</strong> is, whether it is all together orbroken into multiple extents. We will calcul<strong>at</strong>e both cases to see how muchdifference this makes.If the file is stored so as to fill all of the sectors of eight adjacent tracks,then the cost to read the first sector will be the time to seek to the first track(assuming this requires a r<strong>and</strong>om seek), then a wait for the initial rot<strong>at</strong>ionaldelay, <strong>and</strong> then the time to read (which is the same as the time to rot<strong>at</strong>e thedisk again). This requires9.5 + 11.1 × 1.5 = 26.2 ms.At this point, because we assume th<strong>at</strong> the next seven tracks require only <strong>at</strong>rack-to-track seek because they are adjacent. Each requiresThe total time required is therefore2.2 + 11.1 × 1.5 = 18.9 ms.26.2ms + 7 × 18.9ms = 158.5ms.If the file’s clusters are spread r<strong>and</strong>omly across the disk, then we mustperform a seek for each cluster, followed by the time for rot<strong>at</strong>ional delay.Once the first sector of the cluster comes under the I/O head, very little timeis needed to read the cluster because only 8/256 of the track needs to rot<strong>at</strong>eunder the head, for a total time of about 5.9 ms for l<strong>at</strong>ency <strong>and</strong> read time.Thus, the total time required is about256(9.5 + 5.9) ≈ 3942msor close to 4 seconds. This is much longer than the time required when thefile is all together on disk!

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

Saved successfully!

Ooh no, something went wrong!