Consider an old-fashioned unzoned disk drive with the following characteristics.
Answer the following questions regarding the disk drive described above.
How many 512 byte sectors are on this disk drive?
20GB / 512B or 40M
How many total tracks (on all cylinders) are on this disk drive?
2048 * 10 or 20480
How many sectors are stored on each single track?
40M / 20k or 2k
How long, in msec, does it take this disk to rotate?
1 min / 10,000 or 60,000 msec / 10,000 or 6 msec
What is the average time, in msec, required to read a random sector of data from the disk?
10 msec + (6 msec/2) or 13 msec
Write a C++ subroutine which is passed an istream
that has been opened to this file.
This routine should attempt to read an integer from the
file. It should return -1, if the read request fails
or reads a negative number. Otherwise, it should return
the number it reads.
Here is a header for your function:
int ReadOne(istream NumS)
int ReadOne(istream NumS) { int retMe = -1 ; NumS >> retMe ; if (NumS.fail() || retMe < 0) return -1 ; else return retMe ; }