操作系统第九次作业

操作系统第九次作业

问题一: 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?

答:

这将导致通过该路径渴望获得旧文件的用户访问得到的是新文件;

解决的办法可以是:

  • 文件删除并且磁盘空间释放之后,立即删除所有相关的链接
  • 如果该文件为共享文件,则对当前文件的共享用户数进行计数,当有一个用户删除该文件时,计数减一,当计数为零时真正删除该文件。
问题二: Consider a file system that uses a modified contiguous-allocation scheme with support for extents. A file is a collection of extents, with each extent corresponding to a contiguous set of blocks. A key issue in such system is the degree of variability in the size of the extents. What are the advantages and disadvantages of the following schemes?

a. All extents are of the same size, and the size is predetermined.

b. Extents can be of any size and are allocated dynamically.

c. Extents can be of a few fixed sizes, and these sizes are predetermined.

答:
请添加图片描述

问题三:What are the advantages of the variant of linked allocation that uses a FAT to chain together the blocks of a file?

答:

优点:

  • 在访问存储在文件中间的块时,能通过追寻存储在FAT中的指针来确定位置,可以做到直接存取通常情况下,大部分的FAT可以被缓存在内存中,因此可以只通过内存访问来确定指针,而不必访问磁盘块,速度也会快很多。
问题四:Consider a system where free space is kept in a free-space list.

a. Consider a file system similar to the one used by UNIX with indexed allocation. How many disk I/O operations might be required to read the contents of a small local file at /a/b/c? Assume that none of the disk blocks is currently being cached.

b. Suggest a scheme to ensure that the pointer to the free space list is never lost as a result of memory failure.

答:

a、读取本地小文件/a/b/c的内容涉及4个磁盘操作:读取包含根目录所在的磁盘块找到a目录所在磁盘块,读取a目录所在磁盘块找到b目录所在磁盘块,读取b目录所在磁盘块找到文件c的FCB、读取包含文件c的磁盘块
到b目录所在磁盘块,读取b目录所在磁盘块找到文件c的FCB、读取包含文件c的磁盘块
b、
将空闲空间列表的指针存放在磁盘上,且可以备份几份。