









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










EECS 482
1
What abstractions does the OS provide above I/O devices (viz.
disks)?
Problem: lots of different brands of disks, disk interfaces, and
disk controllers, each with their own custom control inter-face. Same is true of any I/O device (network card, videocard, keyboard, mouse, etc.) Add a “device driver” layer to hide this diversity/complexityAn abstraction makes things “better” for things that use the
abstraction• threads: user doesn’t have to worry about sharing CPU• addresses spaces: user doesn’t have to worry about shar-
ing physical memory (or physical memory size)
work
worrying about differences in devices (e.g. the deviceregisters used to control the device)
millions of hardware devices
device drivers rest of operating system
virtual interface physical interface
EECS 482
2
Peter M. Chen
Disk geometry
platters
circles of data (called
tracks
). The set of tracks at the
same radial distance is called a
cylinder
sectors
Accessing a disk
of 49 MB/s on Seagate Barracuda 1181677LW)
Inner Track
Outer Track
Sector
Actuator
Head
Platter
Arm
EECS 482
4
Re-order a set of disk accesses to decrease the total positioning
time• can be implemented in the OS, or in the disk hardware FCFS (first come, first served)
SCAN: sweep the disk from one end to the other, then back
again (sometimes called “Elevator algorithms”). We usethe variant of SCAN called “LOOK” (when sweepingtoward the end, stop if there are no requests beyond thecurrent point)• e.g. 53->37->14->65->67->98->122->124->183• total head movement: 208 tracks (average 26 per seek) C-SCAN: always sweep the disk from beginning to end, then
seek all the way back to the beginning and repeat. Disk scheduling only improves positioning time with multiple
outstanding requests (otherwise service the sole request)
EECS 482
5
A file system is an OS abstraction to make the disk easier to
use How to map file space onto disk space?
virtual and physical address spaces used the same typeof “names” (i.e. addresses)
Overall question: how to organize files on disk
file on disk?
Need an initial structure that describes the object
Unix
the file, e.g. file size, modification date, permissions
Many ways to organize data on diskUsage patterns guide our design choices
whole file (the alternative is random access)
files
disk file system
user
virtual interface physical interface
EECS 482
7
Peter M. Chen
Indexed files are like a shallow treeCould change this to a multi-level tree This allows really big files without wasting header space for
small files
How many accesses to get 1 block of data?
diskblock 18
diskblock 50
diskblock 8
diskblock 15
diskblock 18
diskblock 50
diskblock 8
diskblock 15
level 1node level 2node
level 2node ...
diskblock 8
diskblock 15
diskblock 75
diskblock 40
level 2
level 1node
node
diskblock 18
diskblock 50
EECS 482
8
Peter M. Chen
Pros and cons
needing to pre-allocate a contiguous segment?
How to specify which file you want to access?
(viz. the disk location of the file header)
Typically, the user provides a symbolic name (e.g. english
name, icon); OS translates name to a numeric file header(or disk location of the file header)• alternative is to describe the contents of the file, have the
OS find the name by looking through the files for thatcontent. This is usually done by databases on top of filesystems.
Lots of ways to translate from symbolic name to file header’s
disk block #• e.g. hash table, expandable array, etc.• the data structure that does the mapping is called a
direc-
tory
EECS 482
10
Peter M. Chen
Current working directory: a shortcut for the user and the sys-
tem• cache the file header # for the “current” directory• allows a user to specify a file name relative to the current
directory
entire directory from /
Reducing positioning overhead by taking advantage of usage
patterns
Each disk has a file system
of
another disk’s
file system (this entry is called a
“mount point”)
E.g. CAEN workstation % ls /afs/
kernel/
sbin/
bin@
lib@
template-server@
core
lost+found/
template-server-ro@
dev/
nfs/
tmp/
devices/
opt/
usr/
etc/
platform/
var/
export/
proc/
vol/
home/
root/
/bin is a normal
directory
in
/
/usr points to
the
root
file
system
of
disk
1
/var points to
the
root
file
system
of
disk
2
/afs points to
the
root
file
system
of
a
distributed
file
system
Windows: disks are made visible under my_computer/
Unix: can mount disks at any place in the directory hierarchy
EECS 482
11
File systems have lots of data structures on disk
indirect blocks, etc.
File caches speed access to all these types of dataChanging random disk I/O to sequential I/O can help some-
what• throughput increases dramatically• response time for small requests doesn’t improve Changing disk I/O to memory access helps a lot more
memory
faster performance
Why have two mechanisms that both cache disk data in mem-
ory? Memory-mapped files
spaces
and
files
backing store for the file as being allocated to the diskblocks for that file
knows how to cache files. Memory-mapping makes fileslook like an address space, so VM cache can deal withit.
EECS 482
13
How to fix the problem in the prior example?Can careful ordering solve the problem of transferring money
from Peter’s account to Janet’s account? What 482 concept does this remind you of?
Used a lot in databases. For us, the main component is atomic-
ity (all or nothing) begin
disk writedisk writedisk write
...
end (this is
“commits”
the
transaction)
Basic atomic unit provided by the hardware is writing a single
sector to disk How to make an arbitrary sequence of updates atomic using a
single sector update? Shadowing
keep a pointer to which is the current version
new version when you want to commit the changes
EECS 482
14
Logging
changes
(including commit) but before writing the in-placecopy?
Almost all file systems since 1985 use transactions (using log-
ging) to make atomic a group of updates to the file systemmetadata• why don’t file systems provide atomic transactions for
data updates?
Distributed file system: file system that distributes where data
is actually stored, but unifies the view of this distributedstorage.• allows access to files stored on remote computers (with
same interface as to local files).
Benefits
model)