1
|
UNIT
2/LECTURE 1 |
|||||||||||||||||||||||||||
|
File-System Interface
File
Concept
Access
:Methods
Directory
Structure
Protection
Consistency
Semantics File Concept
Contiguous
logical address space
Types:
Data
I.
numeric
II.
character
III.
binary
Program File Attributes
Name only information kept in
human-readable form.
Type needed for systems that support
different types.
Location pointer to file location on
device.
Size current file size.
Protection controls who can do reading,
writing, executing.
Time, date, and user
identification data for protection, security, and usage monitoring.
Information
about files are kept in the directory structure, which is maintained on the
disk. File Operations
create
write
read
reposition
within file file seek
delete
truncate
open(Fi)
search the directory structure on disk for entry Fi, and
move the content of entry to memory.
close
(Fi) move the content of entry Fi in
memory to directory structure on disk. File Types name, extension 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 Directory
Structure
A
collection of nodes containing information about all files. Information in a Device Directory
Name
Type
Address
Current
length
Maximum
length
Date
last accessed (for archival)
Date
last updated (for dump)
Owner
ID (who pays)
Protection
information (discuss later) Operations Performed on Directory
Search
for a file
Create
a file
Delete
a file
List
a directory
Rename
a file
Traverse
the file system Organize the Directory (Logically) to Obtain
Efficiency
locating a file quickly.
Naming
convenient to users.
Two
users can have same name for different files.
The
same file can have several different names.
Grouping
logical grouping of files by properties, (e.g., all Pascal programs, all
games,
) Single-Level Directory
A
single directory for all users.
Naming
problem
Grouping
problem Two-Level Directory Separate directory for each user
Path
name
Can
have the saem file name for different user
Efficient
searching
No
grouping capability
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 2 |
|||||||||||||||||||||||||||
|
Tree-Structured Directories
Efficient
searching
Grouping
Capability
Current
directory (working directory)
cd /spell/mail/prog
type list
Absolute
or relative path name
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 /spell/mail mkdir
count
Deleting
mail ή deleting the entire subtree rooted
by mail. Acyclic-Graph Directories
Have
shared subdirectories and files.
Two
different names (aliasing)
If
dict deletes list ή dangling pointer. Solutions:
Backpointers,
so we can delete all pointers.
Backpointers
using a daisy chain organization.
Entry-hold-count
solution. General Graph Directory
How
do we guarantee no cycles?
Allow
only links to file not subdirectories.
Garbage
collection.
Every
time a new link is added use a cycle detection Protection
File
owner/creator should be able to control:
what
can be done
by
whom
Types
of access
Read
Write
Execute
Append
Delete
List Access Lists and Groups
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 3 |
|||||||||||||||||||||||||||
|
File-System Implementation
File-System
Structure
Allocation
Methods
Free-Space
Management
Directory
Implementation
Efficiency
and Performance
Recovery File-System Structure
Layered File System A Typical File Control Block In-Memory File System Structures ·
The
following figure illustrates the necessary file system structures provided by
the operating systems.
Directory Implementation
I.
decreases
directory search time
II.
collisions situations where two file names
hash to the same location
III.
fixed
size Allocation Methods
Contiguous Allocation
Block to be accessed = ! + starting
address Displacement into block = R Contiguous Allocation of Disk Space Extent-Based Systems
I.
Extents
are allocated for file allocation
II.
A
file consists of one or more extents.
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 4 |
|||||||||||||||||||||||||||
|
Linked Allocation
Block to be accessed is the Qth
block in the linked chain of blocks representing the file. Displacement into block = R + 1 File-allocation table (FAT)
disk-space allocation used by MS-DOS and OS/2. File-Allocation Table Indexed Allocation
Q = displacement into index table R = displacement into block Indexed Allocation Mapping
Combined Scheme:
UNIX (4K bytes per block)
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 5 |
|||||||||||||||||||||||||||
|
Free-Space Management
§ block size = 212 bytes § disk size = 230 bytes (1
gigabyte) § n = 230/212 =
218 bits (or 32K bytes)
·
Counting
a. Pointer to free list b. 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 c. Solution: Ψ
Set
bit[i] = 1 in disk Ψ
Allocate
block[i] Ψ
Set
bit[i] = 1 in memory Directory Implementation
o
decreases
directory search time o
collisions situations where two file names
hash to the same location o
fixed
size Linked Free Space List on Disk Overview of Mass Storage Structure
o
Busses
vary, including EIDE, ATA, SATA, USB, Fibre Channel, SCSI o
Host
controller in
computer uses bus to talk to disk controller built into drive or
storage array Moving-head Disk Machanism Disk Structure
o
Sector
0 is the first sector of the first track on the outermost cylinder. o
Mapping
proceeds in order through that track, then the rest of the tracks in that
cylinder, and then through the rest of the cylinders from outermost to
innermost.
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 6 |
|||||||||||||||||||||||||||
|
Disk Scheduling
Head
pointer 53 FCFS Illustration shows total head movement of 640
cylinders. SSTF
SCAN
C-SCAN
C-LOOK
Selecting a Disk-Scheduling Algorithm
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 7 |
|||||||||||||||||||||||||||
|
I/O Systems
Objectives
I/O Hardware
·
Direct
I/O instructions ·
Memory-mapped I/O A Typical PC Bus Structure Polling ·
Determines
state of device o command-ready o busy o Error ·
Busy-wait cycle to wait for I/O from device Interrupts ·
CPU
Interrupt-request line triggered by I/O device ·
Interrupt
handler receives interrupts ·
Maskable to ignore or delay some interrupts ·
Interrupt
vector to dispatch interrupt to correct handler o
Based
on priority o
Some
nonmaskable ·
Interrupt
mechanism also used for exceptions Interrupt-Driven I/O Cycle Direct Memory Access
Six Step Process to Perform DMA Transfer Application I/O Interface
I.
Character-stream
or block
II.
Sequential
or random-access
III.
Sharable
or dedicated
IV.
Speed
of operation
V.
read-write,
read only, or write
only A Kernel I/O Structure
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 8 |
|||||||||||||||||||||||||||
|
Characteristics of I/O Devices Block and Character Devices
o
Commands
include get, put o
Libraries
layered on top allow line editing Blocking and Nonblocking I/O
o
Difficult
to use o
I/O
subsystem signals process when I/O completed Two I/O Methods
Synchronous Asynchronous Device-status Table Kernel I/O Subsystem
Error Handling
|
|||||||||||||||||||||||||||
|
UNIT
2/LECTURE 9 |
|||||||||||||||||||||||||||
|
I/O Protection
o
All
I/O instructions defined to be privileged o
I/O
must be performed via system calls 4
Memory-mapped
and I/O port memory locations must be protected too Use of a System Call to Perform I/O Kernel Data Structures
I/O Requests to Hardware Operations
o
Determine
device holding file o
Translate
name to device representation o
Physically
read data from disk into buffer o
Make
data available to requesting process o
Return
control to process Life Cycle of An I/O Request
|
|||||||||||||||||||||||||||