OS_12__Mass-Storage_and_File_System
OS_12__Mass-Storage_and_File_System
and
File System
Outline
• HDD Scheduling
• File Access Methods
• File Sharing
• File Protection
• File Allocation Methods
• Free-Space Management
HDD Scheduling
• The operating system is responsible for using hardware efficiently
— for the disk drives, this means having a fast access time and disk
bandwidth
• Minimize seek time
• Seek time seek distance
• Disk bandwidth is the total number of bytes transferred, divided by
the total time between the first request for service and the
completion of the last transfer
Disk Scheduling (Cont.)
• There are many sources of disk I/O request
• OS
• System processes
• Users processes
• I/O request includes input or output mode, disk address,
memory address, number of sectors to transfer
• OS maintains queue of requests, per disk or device
• Idle disk can immediately work on I/O request, busy disk means
work must queue
• Optimization algorithms only make sense when a queue exists
Disk Scheduling (Cont.)
• In the past, operating system responsible for queue
management, disk drive head scheduling
• Now, built into the storage devices, controllers
• Just provide Logical Block Addressing (LBA), handle sorting of
requests
• Some of the algorithms they use described next
Disk Scheduling (Cont.)
• Note that drive controllers have small buffers and can manage a
queue of I/O requests (of varying “depth”)
• Several algorithms exist to schedule the servicing of disk I/O
requests
• The analysis is true for one or many platters
• We illustrate scheduling algorithms with a request queue (0-199)
98, 183, 37, 122, 14, 124, 65, 67
Head pointer 53
First-Come, First-Served (FCFS) Algorithm
Illustration shows total head movement of 640 cylinders
Shortest-Seek-Time-First (SSTF) Algorithm
• Shortest Seek Time First selects the request with the
minimum seek time from the current head position
• SSTF scheduling is a form of SJF scheduling; may cause
starvation of some requests
• Illustration shows total head movement of 236 cylinders
SCAN Algorithm
• The disk arm starts at one end of the disk, and moves
toward the other end, servicing requests until it gets to
the other end of the disk, where the head movement is
reversed and servicing continues.
• SCAN algorithm Sometimes called the elevator algorithm
• Illustration shows total head movement of 236 cylinders
(Suppose head is currently at 53 and was previously at 58)
• But note that if requests are uniformly dense, largest
density at other end of disk and those wait the longest
SCAN (Cont.)
Circular SCAN (C-SCAN) Algorithm
• Provides a more uniform wait time than SCAN
• The head moves from one end of the disk to the other,
servicing requests as it goes
• When it reaches the other end, however, it immediately returns
to the beginning of the disk, without servicing any requests on
the return trip
• Treats the cylinders as a circular list that wraps around
from the last cylinder to the first one
• Figure
Direct Access
• A file is fixed length logical records
• Operations
• read n
• write n
• position to n
• read next
• write next
• rewrite n
n = relative block number
Methods:
1. Contiguous Allocation
2. Linked Allocation
3. Indexed Allocation
Contiguous Allocation
Each file occupies set of contiguous blocks
• Best performance in most cases
• Simple – only starting location (block #) and length (number of blocks) are
required
• Problems include:
Finding space for file,
Knowing file size,
External fragmentation, need for compaction off-line (downtime) or
on-line
Extent-Based Systems
• Many newer file systems (i.e., Veritas File System) use a modified
contiguous allocation scheme
• Extent-based file systems allocate disk blocks in extents
• An extent is a contiguous block of disks
• Extents are allocated for file allocation
• A file consists of one or more extents
Linked Allocation