Chapter 10: File-System Interface
Chapter 10: File-System Interface
Operating System Concepts with Java – 8th Edition 10.1 Silberschatz, Galvin and Gagne ©2009
Chapter 10: File-System Interface
File Concept
Access Methods
Directory Structure
File-System Mounting
Operating System Concepts with Java – 8th Edition 10.2 Silberschatz, Galvin and Gagne ©2009
File Concept
Operating System Concepts with Java – 8th Edition 10.3 Silberschatz, Galvin and Gagne ©2009
File Structure
Operating System Concepts with Java – 8th Edition 10.4 Silberschatz, Galvin and Gagne ©2009
File Attributes
Operating System Concepts with Java – 8th Edition 10.5 Silberschatz, Galvin and Gagne ©2009
File Operations
Operating System Concepts with Java – 8th Edition 10.7 Silberschatz, Galvin and Gagne ©2009
File Types – Name, Extension
Operating System Concepts with Java – 8th Edition 10.8 Silberschatz, Galvin and Gagne ©2009
Access Methods
Sequential Access
read next
write next
reset
no read after last write
(rewrite)
Direct Access
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
Operating System Concepts with Java – 8th Edition 10.9 Silberschatz, Galvin and Gagne ©2009
Sequential-access File
Operating System Concepts with Java – 8th Edition 10.10 Silberschatz, Galvin and Gagne ©2009
Simulation of Sequential Access on Direct-access File
Operating System Concepts with Java – 8th Edition 10.11 Silberschatz, Galvin and Gagne ©2009
Example of Index and Relative Files
Operating System Concepts with Java – 8th Edition 10.12 Silberschatz, Galvin and Gagne ©2009
Disk Structure
Operating System Concepts with Java – 8th Edition 10.13 Silberschatz, Galvin and Gagne ©2009
A Typical File-system Organization
Operating System Concepts with Java – 8th Edition 10.14 Silberschatz, Galvin and Gagne ©2009
Operations Performed on Directory
Operating System Concepts with Java – 8th Edition 10.15 Silberschatz, Galvin and Gagne ©2009
Tree-Structured Directories
• Absolute path: begins at the root and follows a path down to the
specified file. root/spell/mail/prt/first
• Relative path: defines a path from the current directory. prt/first
given root/spell/mail as current path.
Operating System Concepts with Java – 8th Edition 10.16 Silberschatz, Galvin and Gagne ©2009
Tree-Structured Directories (Cont)
Efficient searching
Grouping Capability
Current directory (working directory)
pwd
cd /spell/mail/prog
Operating System Concepts with Java – 8th Edition 10.17 Silberschatz, Galvin and Gagne ©2009
Tree-Structured Directories (Cont)
Creating a new file is done in current directory
Delete a file
rm <file-name>
Creating a new subdirectory is done in current directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
Operating System Concepts with Java – 8th Edition 10.18 Silberschatz, Galvin and Gagne ©2009
Acyclic-Graph Directories
Have shared subdirectories and files
Only one file exists. Any changes made by one person are
immediately visible to the other.
Operating System Concepts with Java – 8th Edition 10.19 Silberschatz, Galvin and Gagne ©2009
Acyclic-Graph Directories (Cont.)
Operating System Concepts with Java – 8th Edition 10.20 Silberschatz, Galvin and Gagne ©2009
File System Mounting
Operating System Concepts with Java – 8th Edition 10.21 Silberschatz, Galvin and Gagne ©2009
(a) Existing. (b) Unmounted Partition
Operating System Concepts with Java – 8th Edition 10.22 Silberschatz, Galvin and Gagne ©2009
Mount Point
Operating System Concepts with Java – 8th Edition 10.23 Silberschatz, Galvin and Gagne ©2009
Chapter 11: File System Implementation
Operating System Concepts with Java – 8th Edition 10.24 Silberschatz, Galvin and Gagne ©2009
Chapter 11: File System Implementation
File-System Structure
File-System Implementation
Directory Implementation
Allocation Methods
Free-Space Management
Operating System Concepts with Java – 8th Edition 10.25 Silberschatz, Galvin and Gagne ©2009
File-System Structure
File structure
Logical storage unit
Collection of related information
File system organized into layers
File system resides on secondary storage (disks)
Provides efficient and convenient access to disk by
allowing data to be stored, located retrieved easily
File control block – storage structure consisting of
information about a file
Device driver controls the physical device
Operating System Concepts with Java – 8th Edition 10.26 Silberschatz, Galvin and Gagne ©2009
Layered File System
Operating System Concepts with Java – 8th Edition 10.27 Silberschatz, Galvin and Gagne ©2009
File-System Implementation
Operating System Concepts with Java – 8th Edition 10.28 Silberschatz, Galvin and Gagne ©2009
A Typical File Control Block
Operating System Concepts with Java – 8th Edition 10.29 Silberschatz, Galvin and Gagne ©2009
In-Memory File System Structures
the necessary file system structures provided by the OS
Operating System Concepts with Java – 8th Edition 10.31 Silberschatz, Galvin and Gagne ©2009
Allocation Methods
Operating System Concepts with Java – 8th Edition 10.32 Silberschatz, Galvin and Gagne ©2009
Contiguous Allocation of Disk Space
Operating System Concepts with Java – 8th Edition 10.33 Silberschatz, Galvin and Gagne ©2009
Linked Allocation
block = pointer
Operating System Concepts with Java – 8th Edition 10.34 Silberschatz, Galvin and Gagne ©2009
Linked Allocation
Operating System Concepts with Java – 8th Edition 10.35 Silberschatz, Galvin and Gagne ©2009
File-Allocation Table
Operating System Concepts with Java – 8th Edition 10.36 Silberschatz, Galvin and Gagne ©2009
Indexed Allocation
index table
Operating System Concepts with Java – 8th Edition 10.37 Silberschatz, Galvin and Gagne ©2009
Example of Indexed Allocation
Operating System Concepts with Java – 8th Edition 10.38 Silberschatz, Galvin and Gagne ©2009
Indexed Allocation – Mapping (Cont.)
outer-index
Operating System Concepts with Java – 8th Edition 10.39 Silberschatz, Galvin and Gagne ©2009
Combined Scheme: UNIX UFS (4K bytes per block)
Operating System Concepts with Java – 8th Edition 10.40 Silberschatz, Galvin and Gagne ©2009
Free-Space Management
Bit vector (n blocks)
0 1 2 n-1
…
0 block[i] free
bit[i] =
1 block[i] occupied
Operating System Concepts with Java – 8th Edition 10.41 Silberschatz, Galvin and Gagne ©2009
Free-Space Management (Cont.)
Bit map requires extra space
Example:
block size = 212 bytes
disk size = 230 bytes (1 gigabyte)
n = 230/212 = 218 bits (or 32K bytes)
Easy to get contiguous files
Linked list (free list)
Cannot get contiguous space easily
No waste of space
Operating System Concepts with Java – 8th Edition 10.42 Silberschatz, Galvin and Gagne ©2009
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
Operating System Concepts with Java – 8th Edition 10.43 Silberschatz, Galvin and Gagne ©2009
Linked Free Space List on Disk
Operating System Concepts with Java – 8th Edition 10.44 Silberschatz, Galvin and Gagne ©2009
End of Chapter 11
Operating System Concepts with Java – 8th Edition 10.45 Silberschatz, Galvin and Gagne ©2009