Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CMPT 300 Introduction to Operating Systems File Systems Sample Questions.

Similar presentations


Presentation on theme: "1 CMPT 300 Introduction to Operating Systems File Systems Sample Questions."— Presentation transcript:

1 1 CMPT 300 Introduction to Operating Systems File Systems Sample Questions

2 Delayed-Write  Q: Rather than writing updated files to disk immediately when they are closed, many UNIX systems use a delayed write policy in which dirty disk blocks are flushed to disk once every 30 seconds. List advantages and disadvantages of such a scheme  A: Advantage 1: The disk scheduling algorithm (i.e. SCAN) has more dirty blocks to work with at any one time and can thus do a better job of scheduling the disk arm.  Advantage 2: Temporary files may be written and deleted before they ever get to disk.  Disadvantage: File data may be lost if the computer crashes before data is written to disk. 2

3 FAT vs. Linked-List  Q: Compare the performance of a FAT file system to a naive linked-list allocation (where file blocks are linked together via pointers in each block) with respect to number of disk accesses. Be sure to state any assumptions that you are making in terms of what (if anything) is memory resident.  a) Which is faster for random access? Explain. (Assume the file in question is large):  A: The FAT file system is much faster for random access. You read the FAT (once), trace through the links in memory to find the desired block, then read the block from memory (effectively 2 disk accesses). With the linked-allocation, you need to read through (n-1) blocks to randomly access the n th block of the file.  b) Which is faster for sequential access? Explain. (Again assume a large file):  A: This depends on your assumptions. If you are unable to keep the FAT in memory, the linked allocation is faster, since the next block is contained in the previous block. If, on the other hand you assume that the FAT stays in memory, then these two techniques are of equal performance or the FAT could be faster if requests were queued enough to allow better disk scheduling. 3

4 Inodes  Q: Consider a file system with each disk block of size 1KB, and each disk block pointer of size 32-bits (4 bytes). Each file has 13 direct pointers, 4 singly- indirect pointers, a doubly-indirect pointer, and a triply- indirect pointer.  a) What is the largest possible disk size that can be supported? Explain.  A: Since block pointers are 32 bits, there are maximum of 2^32 blocks. Max disk size = 2^32×1KB = 2^42 bytes.  b) What is the largest possible file size that can be supported? Explain.  A: Each disk block is 1 KB, and each address pointer is 4 bytes, hence each single-indirect block can address 1 KB/4 bytes = 256 disk blocks; each doubly- indirect block can address 256*256=64K disk blocks; each triply-indirect block can address 256*256*256=16M disk blocks. Hence the total number of disk blocks that can be addressed by this i- node is 13+256+64K+16M, and the max file size (13+256+64K+16M)*1KB~=16GB 4

5 Deleted File  Q: Consider a file system where a file can be deleted and its disk space reclaimed while links to that file still exist. What problems may occur if a new file is created in the same storage area or with the same absolute path name? How can these problems be avoided?  A: Let F1 be the old file and F2 be the new file. A user wishing to access F1 through an existing link will actually access F2. Note that the access protection for file F1 is used rather than the one associated with F2. This problem can be avoided by ensuring that all links to a deleted file are deleted also. This can be accomplished in several ways:  a. Maintain a list of all links to a file, removing each of them when the file is deleted.  b. Retain the links, removing them when an attempt is made to access a deleted file.  c. Maintain a file reference list (or counter), deleting the file only after all links or references (links) to that file have been deleted. 5


Download ppt "1 CMPT 300 Introduction to Operating Systems File Systems Sample Questions."

Similar presentations


Ads by Google