Lecture 10
Lecture 10
Implementation
Lectures 10
Instructor/Professor
Outline
❑ Address or Location
❑ Current Length
❑ Maximum Length
■ Sequential Access
read next
write next
reset
■ Direct
Access ( n
= relative
block
number)
read n
write n
positio
n to n
Sequential File Organization
Indexed Sequential or Indexed
File Organization
Direct Access File Organization
Protection
■ File Structure
■ Logical Storage Unit with collection of related
information
❑ File System resides on secondary storage
(disks).
■ To improve I/O efficiency, I/O transfers between memory and
disk are performed in blocks.
❑ Read/Write/Modify/Access each block on disk.
■ File system organized into layers.
■ File control block - storage structure
consisting of information about a file.
File System Mounting
File Implementations 39
CS-4513, D-Term 2007
FAT File Systems
■ Advantages
❑ Advantages of Linked File System
❑ FAT can be cached in memory
❑ Searchable at CPU speeds, pseudo-random access
■ Disadvantages
❑ Limited size, not suitable for very large disks
❑ FAT cache describes entire disk, not just open files!
❑ Not fast enough for large databases
Index table
Indexed Allocation
43
Indexed Allocation (cont.)
■ Need index table.
■ Supports sequential, direct and indexed access.
■ Dynamic access without external fragmentation,
but have overhead of index block.
❑ Mapping from logical to physical in a file of maximum size of
256K words and block size of 512 words. We need
only 1 block for index table.
■ Mapping - <Q,R>
❑ Q - displacement into index table
❑ R - displacement into block
Indexed Allocation - Mapping
link
link
Indexed Allocation - Multilevel
index 2nd level Index
Index block
link
link
Combined Scheme: UNIX Inode
mode
data
owners
timestamps data
Size block
count data
Direct blocks
data
data
data
data
Single indirect data
double indirect data
Triple indirect
data
48
What is an inode?
Inode table
Directory
i1 Name1
i2 Name2
i3 Name3
i4 Name4
…
Copyright ©: Nahrstedt, Angrave,
…
Abdelzaher
51
Free Space Management
❑ Counting
❑ Linked list of contiguous blocks that are free
❑ Free list node contains pointer and number of free blocks
starting from that address.
Free Space Management
■ 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.
Directory Implementation
■ Linear list of file names with pointers to the data
blocks
■ simple to program
■ time-consuming to execute - linear search to find entry.
■ Sorted list helps - allows binary search and decreases search time.
■ Hash Table - linear list with hash data structure
■ decreases directory search time
■ collisions - situations where two file names hash to the same
location.
■ Each hash entry can be a linked list - resolve collisions by
adding new entry to linked list.
Efficiency and Performance
❑ Efficiency dependent on:
❑ disk allocation and directory algorithms
❑ types of data kept in the files directory entry
❑ Dynamic allocation of kernel structures
❑ Performance improved by:
■ On-board cache - for disk controllers
■ Disk Cache - separate section of main memory for frequently
used blocks. Block replacement mechanisms
❑ LRU
❑ Free-behind - removes block from buffer as soon as next block is
requested.
❑ Read-ahead - request block and several subsequent blocks are read
and cached.
■ Improve PC performance by dedicating section of memory as
virtual disk or RAM disk.
Recovery