File System and Secondary Storage
File System and Secondary Storage
Storage
File Concept
Contiguous logical address space
Types:
Data
numeric
character
binary
Program
Contents (many types) is defined by file’s creator
text file,
source file,
executable file
File Attributes
Name – only information kept in human-readable form
Identifier – unique tag (number) identifies file within file system
Type – needed for systems that support different types
Location – pointer to file location on the device (disk)
Size – current file size
Protection – controls who can do reading, writing, executing
Time, date, and user identification – information kept for
creation time, last modification time, and last use time.
Useful for data for protection, security, and usage monitoring
Many variations, including extended file attributes such as file
checksum
Information kept in the directory structure (on disk), which
consists of “inode” entries for each of the files in the system.
File Operations
Create
Write – at write pointer location
Read – at read pointer location
Reposition within file - seek
Delete
Truncate
Open(Fi) – search the directory structure on disk for inode
entry Fi, and move the content of the entry to memory
Close (Fi) – move the content of inode entry Fi in memory to
directory structure on disk.
File Types – Name, Extension
Access Methods
Sequential Access
General structure
Operations:
read_next () – reads the next portion of the file and
automatically advances a file pointer.
write_next () – append to the end of the file and
advances to the end of the newly written material
(the new end of file).
reset – back to the beginning of the file.
Access Methods
Direct Access
Operations performed
Directory
on directory
Search for a file
Create a file
Delete a file
Files
F1 F2 F4
F3 List a directory
Fn
Rename a file
Naming problem
Grouping problem
Two-Level Directory
Separate directory for each user
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
Tree-Structured Directories
Efficient searching
Grouping Capability
Acyclic-Graph Directories
No external fragmentation
Each block contains pointer to next block
Free space management system called when new block
needed
Locating a block can take many I/Os and disk seeks
Reliability can be a problem (what if one of the pointers
get corrupted?)
Improve efficiency by clustering blocks into groups but
increases internal fragmentation
Linked Allocation (Cont.)
Indexed Allocation
Indexed allocation
Each file has its own index block(s) of pointers to its data
blocks
In linked allocation, pointers to the blocks are scattered with
the blocks themselves all over the disk and need to be
retrieved in order.
Indexed allocation solves this problem by bringing all the
pointers together into one location: the index block.
0 1 2 n-1
…
1 block[i] free
bit[i] = {
0 block[i] occupied
CPUs have instructions to return offset within word of first “1” bit
Free List
Counting
Because space is frequently contiguously used and freed,
with contiguous-allocation allocation, extents, or clustering
Keep address of first free block and count of following
free blocks
Free space list then has entries containing addresses
and counts
Disk 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
Seek time is the time for the disk arm to move the heads
to the cylinder containing the desired sector.
Rotational latency
It is the additional time waiting for the disk arm to rotate
the desired sector to the disk head.
Disk bandwidth
It 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 be queued.
Optimization algorithms only make sense when a
queue exists
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)
Head pointer 53
FCFS
Illustration shows total head movement of 640 cylinders
SSTF
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