65.1k views
2 votes
one way to use contiguous allocation of the disk and not suffer from holes is to compact the disk every time a file is removed. since all files are contiguous, copying a file requires a seek and rotational delay to read the file, followed by the transfer at full speed. writing the file back requires the same work. assumingaseek time of 5 msec, arotational delay of 4 msec, a transfer rate of 80 mb/sec, and an average file size of 8 kb, howlong does it taketoread a file into main memory and then write it back to the disk at a newlocation? usingthese numbers, howlong would it taketocompact half of a 16-gb disk?

1 Answer

2 votes

Final answer:

To read and write an 8 KB file with a 80 MB/sec transfer rate, 5 ms seek time, and 4 ms rotational delay, it would take approximately 18.196 ms. Compacting half of a 16 GB disk would take roughly 5.3 hours when moving files with these properties.

Step-by-step explanation:

To calculate how long it takes to read a file into main memory and then write it back to the disk at a new location, we need to consider the seek time, rotational delay, and transfer rate. For an 8 kilobyte (KB) file, the total time to read and write the file will be the sum of the seek time, rotational delay, and the time taken to transfer the file twice (once for reading and once for writing).

Firstly, the seek time and the rotational delay occur both for reading and writing. So, this will be:

(5 ms seek time + 4 ms rotational delay) * 2 = 18 ms (for both reading and writing).

Next, we calculate the time to transfer 8 KB of data with a transfer rate of 80 MB/sec.

Since 1 MB = 1,024 KB, the transfer rate in KB/sec is 80 * 1,024 KB/sec. We need to transfer 8 KB, so:


(8 KB / (80 * 1,024) KB/sec) * 1,000 = 0.098 ms (for one transfer, either read or write).

Since we have to both read and write the file, the transfer time doubles:
0.098 ms * 2 = 0.196 ms.

Add the transfer time to the seek time and rotational delay:
18 ms + 0.196 ms = 18.196 ms (for both reading and writing the file).

Now, to compact half of a 16-GB disk, assuming an average file size of 8 KB, there are (16 GB / 8 KB) files for a full disk, and therefore (8GB / 8KB) files for half of the disk. We divide 8 GB by 8 KB to obtain the number of files:

8 GB is 8 * 1,024 * 1,024 KB
(8 * 1,024 * 1,024) KB / 8 KB = 1,048,576 files to be moved

Multiplying this number by 18.196 ms gives the total time to compact half of the disk, which equals:

18.196 ms/file * 1,048,576 files = 19072747.296 ms or approximately 19072.747 seconds or roughly 5.3 hours.

User Brian Mego
by
8.3k points