In a computer system, four files of size 11050 bytes, 4990 bytes, 5170 bytes…
2005
In a computer system, four files of size 11050 bytes, 4990 bytes, 5170 bytes and 12640 bytes need to be stored. For storing these files on disk, we can use either 100 byte disk blocks or 200 byte disk blocks (but can't mix block sizes). For each block used to store a file, 4 bytes of bookkeeping information also needs to be stored on the disk. Thus, the total space used to store a file is the sum of the space taken to store the file and the space taken to store the book keeping information for the blocks allocated for storing the file. A disk block can store either bookkeeping information for a file or data from a file, but not both. What is the total space required for storing the files using 100 byte disk blocks and 200 byte disk blocks respectively?
- A.
35400 and 35800 bytes
- B.
35800 and 35400 bytes
- C.
35600 and 35400 bytes
- D.
35400 and 35600 bytes
Attempted by 16 students.
Show answer & explanation
Correct answer: C
Solution approach: For each file, compute data blocks = ceil(file size / block size). Each data block requires 4 bytes of bookkeeping, which are stored in bookkeeping blocks: bookkeeping blocks = ceil(4 * data blocks / block size). Total space = (data blocks + bookkeeping blocks) * block size.
Using 100-byte blocks:
File 11050 bytes: data blocks = ceil(11050/100) = 111; bookkeeping bytes = 111*4 = 444; bookkeeping blocks = ceil(444/100) = 5; total blocks = 111+5 = 116; space = 116*100 = 11600 bytes.
File 4990 bytes: data blocks = ceil(4990/100) = 50; bookkeeping bytes = 50*4 = 200; bookkeeping blocks = ceil(200/100) = 2; total blocks = 50+2 = 52; space = 52*100 = 5200 bytes.
File 5170 bytes: data blocks = ceil(5170/100) = 52; bookkeeping bytes = 52*4 = 208; bookkeeping blocks = ceil(208/100) = 3; total blocks = 52+3 = 55; space = 55*100 = 5500 bytes.
File 12640 bytes: data blocks = ceil(12640/100) = 127; bookkeeping bytes = 127*4 = 508; bookkeeping blocks = ceil(508/100) = 6; total blocks = 127+6 = 133; space = 133*100 = 13300 bytes.
Total space with 100-byte blocks = 11600 + 5200 + 5500 + 13300 = 35600 bytes.
Using 200-byte blocks:
File 11050 bytes: data blocks = ceil(11050/200) = 56; bookkeeping bytes = 56*4 = 224; bookkeeping blocks = ceil(224/200) = 2; total blocks = 56+2 = 58; space = 58*200 = 11600 bytes.
File 4990 bytes: data blocks = ceil(4990/200) = 25; bookkeeping bytes = 25*4 = 100; bookkeeping blocks = ceil(100/200) = 1; total blocks = 25+1 = 26; space = 26*200 = 5200 bytes.
File 5170 bytes: data blocks = ceil(5170/200) = 26; bookkeeping bytes = 26*4 = 104; bookkeeping blocks = ceil(104/200) = 1; total blocks = 26+1 = 27; space = 27*200 = 5400 bytes.
File 12640 bytes: data blocks = ceil(12640/200) = 64; bookkeeping bytes = 64*4 = 256; bookkeeping blocks = ceil(256/200) = 2; total blocks = 64+2 = 66; space = 66*200 = 13200 bytes.
Total space with 200-byte blocks = 11600 + 5200 + 5400 + 13200 = 35400 bytes.
Answer: 35600 bytes (100-byte blocks) and 35400 bytes (200-byte blocks).