Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11: File System Implementation. 11.2/27 Chapter 11: File System Implementation Chapter 11: File System Implementation File-System Structure File-System.

Similar presentations


Presentation on theme: "Chapter 11: File System Implementation. 11.2/27 Chapter 11: File System Implementation Chapter 11: File System Implementation File-System Structure File-System."— Presentation transcript:

1 Chapter 11: File System Implementation

2 11.2/27 Chapter 11: File System Implementation Chapter 11: File System Implementation File-System Structure File-System Implementation Directory Implementation Allocation Methods Free-Space Management Efficiency and Performance

3 11.3/27 Objectives To describe the details of implementing local file systems and directory structures To describe the implementation of remote file systems To discuss block allocation and free-block algorithms and trade-offs

4 11.4/27 About disk a convenient medium for storing multiple files: A disk can be rewritten in place; it is possible to read a block from the disk, modify the block, and write it back into the same place. A disk can access directly any given block of information it contains. Thus, it is simple to access any file either sequentially or randomly, and switching from one file to another requires only moving the read-write heads and waiting for the disk to rotate. to improve efficiency I/O transfers between memory and disk are performed in units of blocks. Each block has one or more sectors. P411

5 11.5/27 Two different design problems of File system defining how the file system should look to the user. This task involving defining a file and its attributes, the operations allowed on a file, and the directory structure for organizing files. Creating algorithms and data structures to map the logical file system onto the physical secondary-storage devices. P412

6 11.6/27 Layered File System

7 11.7/27 logical file system manages the directory structure to provide the file organization module with the information the latter needs, given a symbolic file name. It maintains file structure via file-control blocks. A file-control block (FCB) contains information about the file, including ownership, permissions, and location of the file contents. The logical file system is also responsible for protection and security. P413

8 11.8/27 A Typical File Control Block

9 11.9/27 Directory Implementation Linear list of file names with pointer to the data blocks. simple to program time-consuming to execute Hash Table – linear list with hash data structure. decreases directory search time collisions – situations where two file names hash to the same location P420

10 11.10/27 Allocation Methods An allocation method refers to how disk blocks are allocated for files: Contiguous allocation Linked allocation Indexed allocation P421

11 11.11/27 Contiguous Allocation Each file occupies a set of contiguous blocks on the disk 文件目录中存放起始盘块号和块数。 优点:访问容易,速度快 缺点: 分配算法复杂(最先适应、 最优适应) 外碎片问题 必须事先知道文件的长度, Files cannot grow P421

12 11.12/27 Contiguous Allocation of Disk Space

13 11.13/27 Linked Allocation 基本思想:每个文件由磁盘块链表组成,每一个盘块含有指 向下一盘块的指针。 Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. 文件目录中存放指向第一个盘块和最后一个盘块的指针。 优点:实现了离散分配;无外碎片;文件大小可变。 缺点:只能顺序访问;指针占空间;链断致命。 改进措施 1 :按簇分配 改进措施 2 :链接信息专门存放,形成 FAT ;双 FAT 更安全。 P423

14 11.14/27 Linked Allocation 16 1 10 25

15 11.15/27 File-Allocation Table end of file

16 11.16/27 Indexed Allocation 基本思想:为每个文件分配一个索引块,把分配给该文件 的所有盘块号,都记录在该索引块中。 优点:支持直接访问;无外碎片。 缺点:浪费空间;索引块的大小问题 管理大文件的改进措施 链接( linked scheme ) 多级索引( Multilevel index ) 组合策略( Combined scheme ) UNIX 采用 P425-426

17 11.17/27 Example of Indexed Allocation

18 11.18/27 Indexed Allocation – Mapping (Cont.)  outer-index index table file

19 11.19/27 Combined Scheme: UNIX (4K bytes per block)

20 11.20/27 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  0  block[i] free 1  block[i] occupied For example, consider a disk where blocks 2, 3, 3, 5, 8, 9, 10, 11, 12, 13/ 17,15,25,26, and 27 arc free and the rest of the blocks are allocated. The free-space bit map would be P429

21 11.21/27 Free-Space Management (Cont.) Bit map requires extra space Example: block size = 2 12 bytes disk size = 2 30 bytes (1 gigabyte) n = 2 30 /2 12 = 2 18 bits (or 32K bytes) Easy to get contiguous files

22 11.22/27 Free-Space Management (Cont.) Linked list (free list) Cannot get contiguous space easily No waste of space P430

23 11.23/27 Linked Free Space List on Disk

24 11.24/27 Free-Space Management (Cont.) Grouping: store the addresses of n free blocks in the first free block. The first n-1 of these blocks are actually free. The last block contains the addresses of another n free blocks, and so on. The addresses of a large number of free blocks can now be found quickly Counting: keep the address of the first free block and the number n of free contiguous blocks that follow the first block. Each entry in the free-space list then consists of a disk address and a count. P431

25 11.25/27 Efficiency and Performance Efficiency dependent on: disk allocation and directory algorithms types of data kept in file’s directory entry Performance disk cache – separate section of main memory for frequently used blocks free-behind – removes a page from the buffer as sum as the next page is requested, the previous pages are not likely to be used again and waste buffer space. read-ahead – a requested page and several subsequent pages are read and cached. These pages are likely to be requested after the current page is processed. improve PC performance by dedicating section of memory as virtual disk, or RAM disk P431

26 11.26/27 Recovery Consistency checking – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape, other magnetic disk, optical) Recover lost file or disk by restoring data from backup P435

27 Homework:1 、 2 、 3 、 4 、 6 End of Chapter 11


Download ppt "Chapter 11: File System Implementation. 11.2/27 Chapter 11: File System Implementation Chapter 11: File System Implementation File-System Structure File-System."

Similar presentations


Ads by Google