212k views
2 votes
A file directory contains 50 file entries and occupies one or more disk blocks where the block size is 1000 bytes. Approach 1: Each directory entry contains a file name of length 10 bytes followed by attributes of length t bytes. Approach 2: Each directory entry contains a file name of length 10 bytes followed by a pointer of 10 bytes, which points to the attributes of length t bytes in a separate block.

(a) With t = 10 and approach 1, determine the average number of blocks that must be accessed to find a file entry and read all attributes.

User Tao Venzke
by
7.6k points

1 Answer

3 votes

Final answer:

In approach 1 with t = 10 bytes for attributes, each directory entry is 20 bytes long. Since the block size is 1000 bytes and the directory contains 50 entries, it fits within one block. Consequently, on average only 1 block needs to be accessed to find a file entry and read its attributes.

Step-by-step explanation:

With approach 1, where each directory entry contains a file name of length 10 bytes followed by attributes of length t bytes, if t = 10, then each directory entry is 20 bytes:

  • 10 bytes for the file name
  • 10 bytes for the attributes

Given a directory containing 50 file entries, the total size of the directory is 50 entries * 20 bytes/entry = 1000 bytes. Since the block size is 1000 bytes, the entire directory can fit in a single disk block. Therefore, to find a file entry and read all attributes, you only need to access 1 block on average, as all the information needed is located within that block.

User Pedro Castilho
by
8.6k points