Download Chapter 11: File System Implementation

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Chapter 11:
File System Implementation
Operating System Concepts with Java – 8th Edition
11.1
Silberschatz, Galvin and Gagne ©2009
File-System Structure
„ File structure
z
Logical storage unit
z
Collection of related information
„ File system organized into layers
„ File system resides on secondary storage (disks)
z
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
Operating System Concepts with Java – 8th Edition
11.4
Silberschatz, Galvin and Gagne ©2009
Layered File System
Operating System Concepts with Java – 8th Edition
11.5
Silberschatz, Galvin and Gagne ©2009
File-System Implementation
„ Boot control block contains info needed by system to boot OS from
that volume
„ Volume control block contains volume details
„ Directory structure organizes the files
„ Per-file File Control Block (FCB) contains many details about the file
Operating System Concepts with Java – 8th Edition
11.6
Silberschatz, Galvin and Gagne ©2009
A Typical File Control Block
Operating System Concepts with Java – 8th Edition
11.7
Silberschatz, Galvin and Gagne ©2009
In-Memory File System Structures
„ The following figure illustrates the necessary file system structures
provided by the operating systems.
„ Figure 12-3(a) refers to opening a file.
„ Figure 12-3(b) refers to reading a file.
Operating System Concepts with Java – 8th Edition
11.8
Silberschatz, Galvin and Gagne ©2009
In-Memory File System Structures
Operating System Concepts with Java – 8th Edition
11.9
Silberschatz, Galvin and Gagne ©2009
Allocation Methods
„ An allocation method refers to how disk blocks are allocated for files:
„ Contiguous allocation
„ Linked allocation
„ Indexed allocation
Operating System Concepts with Java – 8th Edition
11.13
Silberschatz, Galvin and Gagne ©2009
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
„
External Fragmentation occur (first fit/ best fit)
„ Files cannot grow
Operating System Concepts with Java – 8th Edition
11.14
Silberschatz, Galvin and Gagne ©2009
Contiguous Allocation of Disk Space
Operating System Concepts with Java – 8th Edition
11.16
Silberschatz, Galvin and Gagne ©2009
Linked Allocation
„ Each file is a linked list of disk blocks: blocks may be scattered
anywhere on the disk.
block
Operating System Concepts with Java – 8th Edition
=
pointer
11.18
Silberschatz, Galvin and Gagne ©2009
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 MSDOS
Operating System Concepts with Java – 8th Edition
11.19
Silberschatz, Galvin and Gagne ©2009
Linked Allocation
Operating System Concepts with Java – 8th Edition
11.20
Silberschatz, Galvin and Gagne ©2009
File-Allocation Table
Operating System Concepts with Java – 8th Edition
11.21
Silberschatz, Galvin and Gagne ©2009
Indexed Allocation
„ Brings all pointers together into the index block
„ Logical view
index table
Operating System Concepts with Java – 8th Edition
11.22
Silberschatz, Galvin and Gagne ©2009
Example of Indexed Allocation
Operating System Concepts with Java – 8th Edition
11.23
Silberschatz, Galvin and Gagne ©2009
Indexed Allocation (Cont.)
„ Need index table
„ Random access
„ Dynamic access without external fragmentation, but have overhead of
index block
Operating System Concepts with Java – 8th Edition
11.24
Silberschatz, Galvin and Gagne ©2009
Free-Space Management
„ Bit vector (n blocks)
0 1
2
n-1
bit[i] =
Operating System Concepts with Java – 8th Edition
678
…
0 ⇒ block[i] free
1 ⇒ block[i] occupied
11.29
Silberschatz, Galvin and Gagne ©2009
Free-Space Management (Cont.)
„ Bit map requires extra space
z
Example:
block size = 212 bytes (4K)
disk size = 230 bytes (1 gigabyte)
n = 230/212 = 218 bits (or 32K bytes)
„ Easy to get contiguous files
Operating System Concepts with Java – 8th Edition
11.30
Silberschatz, Galvin and Gagne ©2009
Free-Space Management (Cont.)
„ Linked list (free list)
z
Cannot get contiguous space easily
z
No waste of space
Operating System Concepts with Java – 8th Edition
11.31
Silberschatz, Galvin and Gagne ©2009
Linked Free Space List on Disk
Operating System Concepts with Java – 8th Edition
11.33
Silberschatz, Galvin and Gagne ©2009
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 (magnetic tape, other magnetic disk, optical)
„ Recover lost file or disk by restoring data from backup
Operating System Concepts with Java – 8th Edition
11.39
Silberschatz, Galvin and Gagne ©2009
Log Structured File Systems
„ Log structured (or journaling) file systems record each update to
the file system as a transaction.
„ All transactions are written to a log.
z
A transaction is considered committed once it is written to the log.
z
However, the file system may not yet be updated.
„ If the file system crashes, all remaining transactions in the log must
still be performed.
Operating System Concepts with Java – 8th Edition
11.40
Silberschatz, Galvin and Gagne ©2009