📝 Indexed allocation Method in File System Implementation (12 MCQs)
📖 From Operating System • 12. File System Implementation • 12 questions available
What is Indexed allocation Method in File System Implementation?
Definition:
Indexed allocation uses an index block containing an array of pointers to all data blocks, enabling direct mapping from logical to physical blocks.
Example:
Accessing logical block retrieves physical address via in one additional I/O operation.
Reason:
Combines benefits of contiguous and linked allocation by supporting both sequential and direct access without external fragmentation, though index block overhead exists for small files.
📝 All Indexed allocation Method in File System Implementation MCQs
Q1. What is the block that stores pointers to a file's data blocks called in indexed allocation?
📖 Explanation: The index block contains the list of pointers that map each logical block of a file to its physical location on disk, which is the defining feature of indexed allocation. A superblock holds file system metadata, not per‑file pointers, so it is incorrect. An inode is a UNIX structure that may contain direct pointers, but the specific term for the pointer list in indexed allocation is the index block. Data blocks store actual file contents, not pointers, making them wrong choices.
Q2. How does indexed allocation enable random access to any block of a file without traversing previous blocks?
📖 Explanation: Indexed allocation keeps an index block that holds a direct pointer for every logical block of the file. When a program requests block k, the system simply reads pointer k from the index block and jumps to the corresponding data block, avoiding any need to walk through earlier blocks. Storing data sequentially does not provide direct pointers, linking blocks requires traversal, and fixed‑size segments alone do not give random‑access capability.
Q3. Why is indexed allocation generally more efficient than linked allocation for large files?
📖 Explanation: Indexed allocation stores an array of pointers in an index block, so the system can jump directly to any data block without following a chain of links. This eliminates the per‑block traversal cost that linked allocation incurs for large files, where many links would have to be read. Reducing seeks is a benefit but not the primary reason; free‑space lists and metadata size are unrelated to the traversal efficiency.
Q4. What is the primary overhead introduced by indexed allocation, especially for very small files?
📖 Explanation: The index block occupies an entire disk block even when only a handful of pointers are needed, leading to internal waste for tiny files. This overhead is the main drawback for small files. External fragmentation is not directly caused by the indexing structure, pointer indirection latency is modest, and maintaining linked lists is characteristic of linked allocation, not indexed allocation.
Q5. In a two‑level indexed allocation scheme, how does the size of the first‑level index block affect the maximum file size compared to a single‑level scheme?
📖 Explanation: A first‑level index block points to many second‑level index blocks, each of which holds additional data‑block pointers. By adding this extra level, the total number of addressable data blocks grows dramatically, allowing larger files than a single‑level scheme that is limited to the pointers that fit in one block. The space occupied does not reduce capacity, and the increase is not a simple doubling but depends on the number of pointers per block.
Q6. A file system uses indexed allocation with a block size of 4 KB and 4‑byte pointers. One index block can hold 1024 pointers. What is the maximum file size that can be addressed with a single index block?
📖 Explanation: Each pointer addresses one 4 KB data block. With 1024 pointers, the index block can reference of data. Therefore the maximum file size reachable with one index block is 4 MB. The other options assume more pointers or larger block sizes, which are not given. The calculation directly follows from multiplying the number of pointers by the block size.
Q7. Given a block size of 1 KB and 4‑byte pointers, each index block holds 256 pointers. If a file is 10 MB, which indexing scheme is required to store the entire file?
📖 Explanation: A 1 KB block holds 256 pointers, so one index block can address . A 10 MB file needs blocks, far exceeding 256. Using a second‑level index, each first‑level pointer can refer to another index block that adds another 256 pointers, giving blocks, enough for 10 MB. Thus double‑level indexing is required, while single‑level is insufficient and three‑level is unnecessary.
Q8. A file uses indexed allocation with a block size of 1024 bytes. To read the byte at offset 5000, which block number must be accessed?
📖 Explanation: The block number is obtained by integer division of the offset by the block size: remainder 904. Zero‑based numbering means the fifth block (index 4) contains the requested byte. If blocks were counted from one, it would be block 5, but the question asks for the block number directly, making block 4 the correct answer. The other choices correspond to off‑by‑one errors.
Q9. A file of 8 KB occupies two data blocks and one index block (4 KB each) using indexed allocation. After the file is deleted, how many bytes of the index block remain unused because only two pointers were needed?
📖 Explanation: An index block of 4 KB equals 4096 bytes. Each pointer occupies 4 bytes, so two pointers use bytes. The unused space is bytes. Option B matches this calculation. Option A would be true only if the index block were completely filled, which it is not. Option C assumes the entire block is unused, and option D represents half the block, both incorrect.
Q10. A file initially occupies one 4 KB data block and an index block. When the file size increases to 10 KB, what additional allocation is required?
📖 Explanation: A 10 KB file needs three 4 KB blocks (12 KB total) to hold its data. The file already has one data block, so two additional data blocks must be allocated. The existing index block can simply store two new pointers, so no new index block is needed. Therefore the correct action is to allocate two more data blocks and update the index block. Allocating only one block would leave the file incomplete, and creating a new index block is unnecessary.
Q11. Assuming each pointer lookup adds a 1 ms overhead, which allocation method provides faster sequential reading for a file consisting of 100 blocks?
📖 Explanation: With linked allocation, the system must follow a pointer for each of the 100 blocks, incurring of extra time. Indexed allocation reads the index block once and then accesses the data blocks sequentially, adding only a single 1 ms lookup. Consequently, indexed allocation yields a faster sequential read. The “both equal” option ignores the per‑block overhead, and “neither” incorrectly assumes the overhead is insignificant.
Q12. Why does indexed allocation simplify file truncation compared to linked allocation?
📖 Explanation: When a file is truncated, indexed allocation permits the system to modify or remove pointers in the index block directly, without walking through a linked list of blocks. This makes truncation a constant‑time operation. Storing the file size does not by itself simplify truncation, fixed‑size blocks still require deallocation, and free‑space maps are used by many schemes, not only linked allocation.