Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11: File System Implementation Hung Q. Ngo KyungHee University Spring 2009

Similar presentations


Presentation on theme: "Chapter 11: File System Implementation Hung Q. Ngo KyungHee University Spring 2009"— Presentation transcript:

1 Chapter 11: File System Implementation Hung Q. Ngo KyungHee University Spring 2009 http://uclab.khu.ac.kr/lectures/2009-1-os.html

2 11.2 Hung Q. Ngo Spring 2009 Operating System Chapter 11: File System Implementation Chapter 11: File System Implementation File-System Structure Allocation Methods Free-Space Management Note: Some slides and/or pictures in the following are adapted from slides ©2005 Silberschatz, Galvin, and Gagne. Many slides generated from my lecture notes by Kubiatowicz.

3 11.3 Hung Q. Ngo Spring 2009 Operating System Objectives To describe the details of implementing local file systems and directory structures To discuss block allocation and free-block algorithms and trade-offs

4 11.4 Hung Q. Ngo Spring 2009 Operating System File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary storage (disks) File system organized into layers File control block – storage structure consisting of information about a file

5 11.5 Hung Q. Ngo Spring 2009 Operating System Layered File System Basic file system: each physical block is identified by its numeric disk address, e.g. drive 1, cylinder 73, track 2, sector 10 File-organization module: translation between logical blocks and physical blocks. Free space management Logical file system: manages directory structure, maintains file structure via file-control blocks (FCB), responsible for protection and security

6 11.6 Hung Q. Ngo Spring 2009 Operating System File-System Implementation

7 11.7 Hung Q. Ngo Spring 2009 Operating System On-Disk File System Structure

8 11.8 Hung Q. Ngo Spring 2009 Operating System In-Memory File System Structure

9 11.9 Hung Q. Ngo Spring 2009 Operating System Opening & Reading a File Per process: store current file pointer, access rights, accounting info, etc. system-wide: location of file on disk, access dates, file size...

10 11.10 Hung Q. Ngo Spring 2009 Operating System Allocation Methods An allocation method refers to how disk blocks are allocated for files: Contiguous allocation Linked allocation Indexed allocation

11 11.11 Hung Q. Ngo Spring 2009 Operating System Contiguous Allocation Each file occupies a set of contiguous blocks on the disk Simple – only starting location (block #) and length (number of blocks) are required Random access Wasteful of space (dynamic storage-allocation problem) Files cannot grow

12 11.12 Hung Q. Ngo Spring 2009 Operating System Linked Allocation Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. Directory table stores pointers to the start and end blocks Each block stores pointer to next block (usually first/last 4bytes) and block data pointer Data block =

13 11.13 Hung Q. Ngo Spring 2009 Operating System Linked Allocation (Cont.) Simple – need only starting address Free-space management system – no waste of space No random access File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2.

14 11.14 Hung Q. Ngo Spring 2009 Operating System File-Allocation Table EOF 0 300

15 11.15 Hung Q. Ngo Spring 2009 Operating System Indexed Allocation Brings all pointers together into the index blocks. Logical view. Random access Dynamic access without external fragmentation, but have overhead of index block. index table

16 11.16 Hung Q. Ngo Spring 2009 Operating System Example of Indexed Allocation

17 11.17 Hung Q. Ngo Spring 2009 Operating System Quiz on Indexed Allocation HDD = 32GB Block size = 512Bytes Maximum file size =256KB How many blocks used to store the index tables?

18 11.18 Hung Q. Ngo Spring 2009 Operating System Combined Scheme: UNIX iNode Table (4K bytes per block) (12)

19 11.19 Hung Q. Ngo Spring 2009 Operating System Memory Management Using iNodes

20 11.20 Hung Q. Ngo Spring 2009 Operating System Free-Space Management Free-space linked list Bitmap

21 11.21 Hung Q. Ngo Spring 2009 Operating System Linked Free Space List on Disk Block #2 Block #3 Quiz: HDD = 20MB Block size = 1KB If disk is totally empty, how many blocks to store the free space linked list? Next block in the linked list

22 11.22 Hung Q. Ngo Spring 2009 Operating System Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i] free 0  block[i] occupied First free block number calculation: (number of bits per word) * (number of 0-value words) + offset of first 1 bit

23 11.23 Hung Q. Ngo Spring 2009 Operating System 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 Linked list (free list) Cannot get contiguous space easily

24 End of Chapter 11


Download ppt "Chapter 11: File System Implementation Hung Q. Ngo KyungHee University Spring 2009"

Similar presentations


Ads by Google