Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2000M.B. Ibáñez Lecture 24 File-System III File System Implementation.

Similar presentations


Presentation on theme: "Fall 2000M.B. Ibáñez Lecture 24 File-System III File System Implementation."— Presentation transcript:

1 Fall 2000M.B. Ibáñez Lecture 24 File-System III File System Implementation

2 Fall 2000M.B. Ibáñez Secondary Storage Management Space must be allocated to files Must keep track of the space available for allocation Space is allocated as one or more contiguous units or portions From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

3 Fall 2000M.B. Ibáñez Preallocation Need the maximum size for the file at the time of creation Difficult to reliably estimate the maximum potential size of the file Tend to overestimated file size so as not to run out of space From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

4 Fall 2000M.B. Ibáñez Portion Size Contiguity of space increases performance Large number of small portions increases the size of tables needed Fixed-size simplifies the reallocation of space Variable-size minimizes waste of unused storage From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

5 Fall 2000M.B. Ibáñez Methods of File Allocation Contiguous allocation –single set of blocks is allocated to a file at the time of creation –only a single entry in the file allocation table starting block and length of the file Fragmentation will occur Will become difficult to find contiguous blocks of sufficient length From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

6 Contiguous File Allocation 01234 56789 1011121314 1516171819 2021222324 2526272829 3031323334 File Allocation Table File NameStart BlockLength FileA FileB FileC FileD FileE 23 95 188 302 263 FileA FileB FileC FileE FileD From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

7 Fall 2000M.B. Ibáñez Methods of File Allocation Chained allocation –allocation on basis of individual block –each block contains a pointer to the next block in the chain –only single entry in the file allocation table starting block and length of file No fragmentation Any free block can be added to the chain No accommodation of the principle of locality From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

8 Chained File Allocation 01234 56789 1011121314 1516171819 2021222324 2526272829 3031323334 File Allocation Table File NameStart BlockLength... FileB5... 1 FileB From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

9 Fall 2000M.B. Ibáñez Methods of File Allocation Indexed allocation –file allocation table contains a separate one- level index for each file –the index has one entry for each portion allocated to the file –the file allocation table contains block number for the index From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

10 Indexed Allocation with Block Portions 01234 56789 1011121314 1516171819 2021222324 2526272829 3031323334 File Allocation Table File NameIndex Block... FileB24 FileB 1 8 3 14 28 From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

11 Indexed Allocation - Var Length Portions 01234 56789 1011121314 1516171819 2021222324 2526272829 3031323334 File Allocation Table File NameIndex Block... FileC24 Start BlockLength 1 28 14 3 4 1 FileB From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

12 Fall 2000M.B. Ibáñez UNIX File Management Files are streams of bytes Types of files –ordinary - contents entered by user or program –directory - contains list of file names and pointers to inodes (index nodes) –special - used to access peripheral devices –named - named pipes From Operating Systems. Internals and Design Principles. W. Stallings. Prentice Hall

13 Fall 2000M.B. Ibáñez UNIX (4K bytes per block) From Operating System Concepts Silbershatz & Galvin

14 Fall 2000M.B. Ibáñez Free-Space Management Bit vector (n blocks) Block number calculation … 012n-1 bit[i] =  0  block[i] free 1  block[i] occupied (number of bits per word) * (number of 0-value words) + offset of first 1 bit From Operating System Concepts Silbershatz & Galvin

15 Fall 2000M.B. Ibáñez 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 –No waste of space Grouping Counting From Operating System Concepts Silbershatz & Galvin

16 Fall 2000M.B. Ibáñez Free-Space Management (Cont.) Need to protect: –Pointer to free list –Bit map 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] = 1 in disk. Allocate block[i] Set bit[i] = 1 in memory From Operating System Concepts Silbershatz & Galvin

17 Fall 2000M.B. Ibáñez 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 –fixed size From Operating System Concepts Silbershatz & Galvin


Download ppt "Fall 2000M.B. Ibáñez Lecture 24 File-System III File System Implementation."

Similar presentations


Ads by Google