CPU Scheduling

Download Report

Transcript CPU Scheduling

File Systems (1)
Readings
r Reading: Disks, disk scheduling (3.7 of
textbook; “How Stuff Works”)
r Reading: File System Implementation (5.15.3 of textbook)
File Concept
r Computers store information on various
storage media
m
Disks, tapes
r The OS provides a logical view of
information storage
m
Define a logical storage unit: file
r Files are mapped by the operating system
to physical devices
Files
r Named collection of related information
recorded on secondary storage
m
m
Logical unit of storage on a device
e.g., helloworld.c, resume.doc
r Can contain programs (source, binary) or
data
r Files have attributes:
m
Name, type, location, size, protection, creation
time etc
File Naming
r Files are named
r Even though files are just a sequence of
bytes, programs can impose structure on
them
m
m
m
Files with a certain standard structure imposed can
be identified using an extension to their name
Application programs may look for specific file
extensions to indicate the file’s type
But as far as the operating system is concerned its
just a sequence of bytes
File Naming
Typical file extensions
File Types
r Many operating systems support several
types of files
r UNIX, Windows have regular files and
directories
r Regular files:
m
m
Contain user information
Can be ASCII (e.g., source code) or binary
(executable)
r Directories
m Maintain information on the structure of the
file system
File Types
r A file is a sequence of bytes
m How does the OS know if a file can be executed?
m Executable must have a specific format
r In Unix the format of an executable is the
following:
m
Header, text, data, relocation bits and symbol table
r Header
m Starts with the magic number identifying the file as
executable
m Followed by sizes of the various pieces of information
m Followed by the address at which execution starts (entry
point)
m Followed by the text and data itself
File Types
(a) An executable file (b) An archive
File Access
r Sequential access
m
m
m
Read all bytes/records from the beginning
Cannot jump around, could rewind or back up
Convenient when medium was magnetic tape
r Random access
m Bytes/records read in any order
m Essential for database systems
File Attributes
r Various meta-data needs to be associated with
files
m
m
m
m
Owner
Creation time
Access permissions / protection
Size etc
r This meta-data is referred to as the file
attributes
m
Maintained in file system data structures for each
file
File Attributes
Possible file attributes
File Operations
1.
2.
3.
4.
5.
6.
Create
Delete
Open
Close
Read
Write
Append
8. Seek
9. Get
attributes
10. Set
Attributes
11. Rename
7.
Directories
r File systems use directories to keep track
of files
r Directory operations
m
m
m
m
m
m
File search
File creation
File deletion
Directory listing
File renaming
File system traversal
Single Level Directories
r All files are contained in the same
directory
r Limitations
m
m
File names must be unique
Must ensure enough characters to make it
easier to have unique file names.
Simple Directories
r When a file is opened, the OS searches its
directory until it finds the name of the file
to be opened.
r It then extracts the attributes and disk
addresses
r The OS now has all the information needed
to access the file
r The number of directories varies from
system to system.
Directories
Single-Level Directory Systems
r A single level directory system
m contains 4 files
m owned by 3 different people, A, B, and C
Two-level Directory Systems
r Letters indicate owners of the directories and files
r There is a directory associated with each user
Hierarchical Directory Systems
A hierarchical directory system
Path Names
r Need to specify file names
r Two methods:
m Absolute path name: Consisting of the path
from the root directory to the file
m Relative path name
• User designates one directory as the current working
directory
• The path name of the current working directory is
implicit in the relative path name
Path Names
A UNIX directory tree
Summary
r This section briefly described the user
interface to files and directories