0
$\begingroup$

I'm working on a problem from my textbook (not homework, just an example), and it asks us to calculate the 'best case' scenario of reading a 1MB file from the hard drive.

I don't know why the right way to calculate the total time involves the max time for a single rotation. Also in the answer they said that a 1MB file would have 10,000 512-byte logical blocks, how is that calculated? Wouldn't a sector have 512-bytes, so wouldn't the file take 1954 512-byte sectors?

This link has a similar question (almost identical), and yet the 1MB file in their example uses 2000 logical blocks.

I suppose my question boils down to, how are the amount of logical blocks determined? And furthermore, what's wrong with my assumptions/calculations?

Here's the information that it gave me:

Parameter Value
Rotational Rate 13,000RPM
TAvgSeek 6ms
Avg # Sectors/track 5,000
Surfaces 4
Sector Size 512-bytes

Here's What I Did:

Here's what my thought process was, first calculate the average time it takes to find the first sector of the file in the track:

Tavg-rotation = (1/2) * 60s/13,000RPM * 1,000ms/sec
Tavg-rotation = 2.30ms

Next, I found the time to transfer a single sector:
Ttrans = 60s/13,000RPM * (1 Track/5000 sector) * 1,000ms/sec
Ttrans = 0.00092308 ms

And then finally I added the time for the spindle to find the track, plus the time to find the first sector of the file, plus the time it takes to read all the sectors in the file:
Ttotal = Tseek + Tavg-rotation + Ttrans*1MB*(1sector/512bytes)
Ttotal = 6ms + 2.30ms + 1.80ms
Ttotal = 10.10ms

This is apparently the wrong answer...

Here's What the Textbook Did:

This is a good check of your understanding of the factors that affect disk performance. First we need to determine a few basic properties of the file and the disk. The file consists of 10,000 512-byte logical blocks. For the disk, Tavg seek = 6 ms, Tmax rotation = 4.61 ms, and Tavg rotation = 2.30 ms.

A. Best case:
In the optimal case, the blocks are mapped to contiguous sectors, on the same cylinder, that can be read one after the other without moving the head. Once the head is positioned over the first sector it takes two >>full rotations (5,000 sectors per rotation) of the disk to read all 10,000 >>blocks.
So the total time to read the file is Tavg seek + Tavg rotation + 2 × >>Tmax rotation = 6 + 2.30 + 9.22 = 17.52 ms.

Computer Systems, A Programmer's Perspective 3ed, pg 631, pg697
Briant & O'Hallaron

I hope I provided enough information!

$\endgroup$
3
  • $\begingroup$ (The T rotations got to be somewhat of a misnomer: time for rotation shouldn't vary much, latency due to rotation does depend on rotational position.) $\endgroup$
    – greybeard
    Commented Dec 14, 2023 at 8:57
  • $\begingroup$ For some reason your first comment's link is giving me a 404, but I'll add the textbook name and title. $\endgroup$ Commented Dec 14, 2023 at 20:51
  • $\begingroup$ Thanks for the headsup, I've formatted and fixed everything. $\endgroup$ Commented Dec 14, 2023 at 21:28

1 Answer 1

1
$\begingroup$

For some reason they say the file has 10,000 sectors instead of 2,000 which may explain the difference.

They also forget that the file is most likely stored over three tracks so you need to add a bit of time twice to get to the next track.

$\endgroup$
5
  • $\begingroup$ (Have you ever wondered whether HD switched to one track per recording surface? Cylinders are so stepper motor actuator. And the time to consider would be head switch time more often than seek to neighbouring cylinder in case of cylinders.) $\endgroup$
    – greybeard
    Commented Dec 14, 2023 at 8:44
  • $\begingroup$ How did you get the 2,000 sectors though? Wouldn't fileSize/sectorSize be the amount of sectors it takes up? $\endgroup$ Commented Dec 14, 2023 at 21:06
  • $\begingroup$ (@PerformingAlbatross: 1954 or 2000 would depend on what exactly the M in 1 MB stood for. If *logical block*&sector meant 512 bytes.) $\endgroup$
    – greybeard
    Commented Dec 14, 2023 at 21:31
  • $\begingroup$ @gnasher729 I can't seem to edit my comment, but I think you've solved my mystery. When I follow the example in the link in my post I get an answer very close to there's (and on a question that's not in the post). So it's the amount of logical blocks that the file takes up that was the issue. The textbook is wrong then I think. I still calculated less than 2000 but my answer is really close now. $\endgroup$ Commented Dec 14, 2023 at 21:35
  • $\begingroup$ @greybeard The textbook mentions in an aside that the prefixes should, for the context of homework, be treated as their SI definitions (K = 10^3, M=10^6 etc.) when doing problems related to disk storage, and using the IEC values for networking. Thanks for your guys help, you've helped me solve it. $\endgroup$ Commented Dec 14, 2023 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.