CS FundamentalsModerateGATE CS
A directory with 10,000 entries is stored as an unsorted linear list. File creation must check that the name does not already exist. Which change speeds up both lookup and creation the most?
- A. Sort the list after every creation
- B. Use contiguous allocation for the directory file
- C. Increase the block size
- D. Store the entries in a hash table (or B-tree) keyed by file name
Correct answer: D. Store the entries in a hash table (or B-tree) keyed by file name
A hash table makes lookup and duplicate checking expected O(1) (a B-tree gives O(log n) and ordered listing, as in ext4 htree or NTFS). A sorted list still needs shifting on insertion.
More Operating Systems questions
- A file system uses a buffer cache with write-back. The system crashes right after a program's write() returned. Which statement is correct?
- Which of these is the correct reason that the Unix rename(old, new) within one file system is widely used to update a file safely (write a…
- A process opens the same file twice with two separate open() calls, getting fd 3 and fd 4, and also calls dup(3) to get fd 5. It then…
- After fork(), a parent and child both write to a file descriptor that was opened before the fork, without OAPPEND. Why do their writes not…
- Which statement about access-control lists (ACLs) versus capability lists is correct?
- A setuid-root program calls access(path, ROK) to check the real user may read path, then calls open(path). Which vulnerability does this…