CMPT 300 Introduction to Operating Systems File Systems

![Delayed-Write ] Q: Rather than writing updated files to disk immediately when they are Delayed-Write ] Q: Rather than writing updated files to disk immediately when they are](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-2.jpg)
![FAT vs. Linked-List ] ] ] Q: Compare the performance of a FAT file FAT vs. Linked-List ] ] ] Q: Compare the performance of a FAT file](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-3.jpg)
![Inodes ] ] ] Q: Consider a file system with each disk block of Inodes ] ] ] Q: Consider a file system with each disk block of](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-4.jpg)
![Deleted File ] Q: Consider a file system where a file can be deleted Deleted File ] Q: Consider a file system where a file can be deleted](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-5.jpg)
- Slides: 5

CMPT 300 Introduction to Operating Systems File Systems Sample Questions 1
![DelayedWrite Q Rather than writing updated files to disk immediately when they are Delayed-Write ] Q: Rather than writing updated files to disk immediately when they are](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-2.jpg)
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
![FAT vs LinkedList Q Compare the performance of a FAT file FAT vs. Linked-List ] ] ] Q: Compare the performance of a FAT file](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-3.jpg)
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 linkedallocation, you need to read through (n-1) blocks to randomly access the nth 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
![Inodes Q Consider a file system with each disk block of Inodes ] ] ] Q: Consider a file system with each disk block of](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-4.jpg)
Inodes ] ] ] Q: Consider a file system with each disk block of size 1 KB, 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× 1 KB = 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=64 K disk blocks; each triply-indirect block can address 256*256=16 M disk blocks. Hence the total number of disk blocks that can be addressed by this i-node is 13+256+64 K+16 M, and the max file size (13+256+64 K+16 M)*1 KB~=16 GB 4
![Deleted File Q Consider a file system where a file can be deleted Deleted File ] Q: Consider a file system where a file can be deleted](https://slidetodoc.com/presentation_image_h/d7d5b3215219691c4d6f3eb57d74112f/image-5.jpg)
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 F 1 be the old file and F 2 be the new file. A user wishing to access F 1 through an existing link will actually access F 2. Note that the access protection for file F 1 is used rather than the one associated with F 2. This problem can be avoided by ensuring that all links to a deleted file are deleted also. This can be accomplished in several ways: S S S 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