Operating System Exercises - Chapter 11-Sol
Operating System Exercises - Chapter 11-Sol
11
CHAPTER
Implementation
Practice Exercises
11.1 Consider a file currently consisting of 100 blocks. Assume that the
file control block (and the index block, in the case of indexed alloca-
tion) is already in memory. Calculate how many disk I/O operations
are required for contiguous, linked, and indexed (single-level) alloca-
tion strategies, if, for one block, the following conditions hold. In the
contiguous-allocation case, assume that there is no room to grow in the
beginning, but there is room to grow in the end. Assume that the block
information to be added is stored in memory.
a. The block is added at the beginning.
b. The block is added in the middle.
c. The block is added at the end.
d. The block is removed from the beginning.
e. The block is removed from the middle.
f. The block is removed from the end.
Answer:
39
40 Chapter 11 File-System Implementation
11.8 Explain how the VFS layer allows an operating system easily to support
multiple types of file systems.
Answer: VFS introduces a layer of indirection in the file system imple-
mentation. In many ways, it is similar to object-oriented programming
techniques. System calls can be made generically (independent of file
system type). Each file system type provides its function calls and data
structures to the VFS layer. A system call is translated into the proper
specific functions for the target file system at the VFS layer. The calling
program has no file-system-specific code, and the upper levels of the
system call structures likewise are file system-independent. The trans-
lation at the VFS layer turns these generic calls into file-system-specific
operations.