Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating System File System Monday, August 11, 2008.

Similar presentations


Presentation on theme: "Operating System File System Monday, August 11, 2008."— Presentation transcript:

1 Operating System File System Monday, August 11, 2008

2 Roadmap File Concept Access Methods Directory Structure
File System Implementation Allocation Methods Free-Space Management File Sharing and Protection 8/11/2008 6:14 PM

3 Free – Space Management
We need a way to keep track of space currently free. This information is needed when we want to create or add (allocate) to a file. When a file is deleted, we need to show what space is freed up. There are several methods, such as bit vector method, free list method, grouping method, counting method, etc. 如何为多个文件分配磁盘空间,以便有效地使用磁盘空间和快速地访问文件。常用的磁盘空间分配方法有三个:连续、链接和索引。 8/11/2008 6:14 PM

4 Bit vector The free-space list is implemented as a bit map or bit vector. Each block is represented by 1 bit. If the block is free, the bit is 1; if the block is allocated, the bit is 0. An example 1 2 n-1 bit[i] =  1  block[i] free 0  block[i] occupied 为了记录空闲磁盘空间,系统需要维护一个空闲空间链表。空闲空间链表记录了所有空闲磁盘空间,即未分配给文件或目录的空间。当创建文件时,搜索空闲空间链表以得到所需要的空间,并分配给新文件。这些空间会从空闲空间链表中删除。 8/11/2008 6:14 PM

5 Bit vector Discussion: Simple to implement
Efficient to find the first free block Easy to get contiguous files Block number calculation: (number of bits per word)*(number of 0-value words) +offset of first 1 bit Bit map requires extra space. Example: block size = 212 bytes disk size = 230 bytes (1 GB) n = 230/212 = 218 bits (or 32K bytes) 8/11/2008 6:14 PM

6 Protection Need to protect: Pointer to free list Bit map Solution:
Must be kept on disk Copy in memory and disk may differ. Cannot allow for block[i] to have a situation where bit[i] = 1 in memory and bit[i] = 0 on disk. Solution: Set bit[i] = 0 in disk. Allocate block[i] Set bit[i] = 1 in memory 8/11/2008 6:14 PM

7 Linked List Linked list (free list): free blocks are chained together, each holding a pointer to the next one free. Cannot get contiguous space easily No waste of space 8/11/2008 6:14 PM

8 Grouping Grouping: In one free block, put lots of pointers to other free blocks. Include a pointer to the next block of pointers. To linked blocks to store the addresses To group n-1 addresses into an address block To use the last address in an address block to point to next address block. Easier to find a large number of free blocks. 将n个空闲块的地址存在第一个空闲块中,这些快的前n-1各确实为空,而最后一个包含另外n个空闲块的地址。 8/11/2008 6:14 PM

9 Counting Counting: Since many free blocks are contiguous, keep a list of dyads < disk address, number of free blocks >. The total list is smaller. 8/11/2008 6:14 PM

10 Roadmap File Concept Access Methods Directory Structure
File System Implementation Allocation Methods Free-Space Management File Sharing and Protection 8/11/2008 6:14 PM

11 File Sharing Sharing of files on multi-user systems is desirable.
Sharing may be done through a protection scheme. On distributed systems, files may be shared across a network. Network File System (NFS) is a common distributed file-sharing method. 8/11/2008 6:14 PM

12 Shared File File system containing a shared file. 8/11/2008 6:14 PM

13 Process of Sharing a File
Situation prior to linking After the link is created After the original owner removes the file 8/11/2008 6:14 PM

14 Multiple Users Most systems have evolved to the concepts of file/directory owner and group User IDs identify users, allowing permissions and protections to be per-user Group IDs allow users to be in groups, permitting group access rights 8/11/2008 6:14 PM

15 Remote File Systems (RFS)
Uses networking to allow file system access between systems Manually via programs like FTP Automatically, seamlessly using distributed file systems Semi automatically via the world wide web 8/11/2008 6:14 PM

16 RFS - Client Server Model
Client-server model allows clients to mount remote file systems from servers Server can serve multiple clients Client and user-on-client identification is insecure or complicated NFS is standard UNIX client-server file sharing protocol CIFS is standard Windows protocol Standard operating system file calls are translated into remote calls 8/11/2008 6:14 PM

17 RFS - Distributed System
Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS implement unified access to information needed for remote computing 8/11/2008 6:14 PM

18 RFS - Failure Modes Remote file systems add new failure modes, due to network failure, server failure Recovery from failure can involve state information about status of each remote request Stateless protocols such as NFS include all information in each request, allowing easy recovery but less security 8/11/2008 6:14 PM

19 File System Reliability
File system is much easier to be destroyed than computer. Threre are several issues about the relaibility of file system, such as backup and consistency 8/11/2008 6:14 PM

20 Backup A file system to be dumped
squares are directories, circles are files shaded items, modified since last dump each directory & file labeled by i-node number 8/11/2008 6:14 PM

21 Backup (cont.) Bit maps used by the logical dumping algorithm
8/11/2008 6:14 PM

22 Consistency Semantics
Consistency semantics specify how multiple users are to access a shared file simultaneously Similar to process synchronization algorithms Andrew File System (AFS) implemented complex remote file sharing semantics Unix file system (UFS) implements: Writes to an open file visible immediately to other users of the same open file Sharing file pointer to allow multiple users to read and write concurrently 8/11/2008 6:14 PM

23 File System States consistent missing block
duplicate block in free list duplicate data block 8/11/2008 6:14 PM

24 Protection File owner/creator should be able to control:
what can be done by whom Types of access Read, Write, Execute, Append, Delete, List The most common approach is to make access dependent on the identity of user. Various users may need different types of access to a file or directory. 8/11/2008 6:14 PM

25 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). Recover lost file or disk by restoring data from backup. 一致性检查程序将目录结构数据与磁盘数据块相比较,并试图纠正所发生的不一致。分配算法和空闲空间管理算法决定了检查程序能发现什么类型的问题,及其如何成功地纠正问题。 由于磁盘有时会出错,所以必须注意确保数据不会永久丢失。为此,可以利用系统程序将磁盘数据备份到另一存储设备如软盘、磁带或光盘。 恢复单个文件或整个磁盘时,只需要从备份中加以恢复就可以了。 8/11/2008 6:14 PM

26 MS – DOS File System The MS-DOS directory entry
Maximum partition for different block sizes The empty boxes represent forbidden combinations 8/11/2008 6:14 PM

27 Keystone Basic idea of different free-space management methods
Issues in file sharing and protection 8/11/2008 6:14 PM

28 Operating System File System Monday, August 11, 2008


Download ppt "Operating System File System Monday, August 11, 2008."

Similar presentations


Ads by Google