Operatin
g
Systems
:
Internals Module 5
and File Management
Design Prof Salim Shaikh
Principle AIKTC
s
Files
■ Data collections created by users
■ The File System is one of the most important parts of the OS
to a user
■ Desirable properties of files:
Long-term existence
• files are stored on disk or other secondary storage and do not disappear when a user
logs off
Sharable between processes
• files have names and can have associated access permissions that permit
controlled sharing
Structure
• files can be organized into hierarchical or more complex structure to reflect the
relationships among files
File Systems
■ Provide a means to store data organized as files as well as
a collection of functions that can be performed on files
■ Maintain a set of attributes associated with the file
■ Typical operations include:
■ Create
■ Delete
■ Open
■ Close
■ Read
■ Write
File Structure
Four terms are
commonly used when
discussing files:
Field Record File Databas
e
Structure Terms
Field Record
■ basic element of data ■ collection of related fields
■ contains a single value that can be treated as a
■ length and data type unit by some application
program
■ fixed or variable length
Database
■ collection of related
data File
■ relationships among ■ collection of similar records
elements of data are ■ treated as a single entity
explicit
■ may be referenced by name
■ designed for use by a
■ access control restrictions
number of different
usually apply at the file
applications
level
File Management
System Objectives
■ Meet the data management needs of the user
■ Guarantee that the data in the file are valid
■ Optimize performance
■ Provide I/O support for a variety of storage device types
■ Minimize the potential for lost or destroyed data
■ Provide a standardized set of I/O interface routines to
user processes
■ Provide I/O support for multiple users in the case of
multiple-user systems
Minimal User
Requirements
▪ Each user:
•should be able to create, delete, read, write and modify files
1
•may have controlled access to other users’ files
2
•may control what type of accesses are allowed to the files
3
•should be able to restructure the files in a form appropriate to the
4 problem
•should be able to move data between files
5
•should be able to back up and recover files in case of damage
6
•should be able to access his or her files by name rather than by
7 numeric identifier
Typical Software Organization
Device Drivers
■Lowest level
■Communicates directly with peripheral devices
■Responsible for starting I/O operations on a
device
■Processes the completion of an I/O request
■Considered to be part of the operating system
Basic File System
■ Also referred to as the physical I/O level
■ Primary interface with the environment outside the
computer system
■ Deals with blocks of data that are exchanged with disk
or tape systems
■ Concerned with the placement of blocks on the
secondary storage device
■ Concerned with buffering blocks in main memory
■ Considered part of the operating system
Basic I/O Supervisor
■ Responsible for all file I/O initiation and termination
■ Control structures that deal with device I/O, scheduling,
and file status are maintained
■ Selects the device on which I/O is to be performed
■ Concerned with scheduling disk and tape accesses to
optimize performance
■ I/O buffers are assigned and secondary memory is
allocated at this level
■ Part of the operating system
Logical I/O
Provides
general-
Enables users purpose
and record I/O
capability Maintains
applications to basic data
access about file
records
Access Method
■ Level of the file system closest to the user
■ Provides a standard interface between applications
and the file systems and devices that hold the data
■ Different access methods reflect different file
structures and different ways of accessing and
processing the data
Elements of File
Management
File Organization and Access
■ File organization is the logical structuring of the records as
determined by the way in which they are accessed
■ In choosing a file organization, several criteria are important:
■ short access time
■ ease of update
■ economy of storage
■ simple maintenance
■ reliability
■ Priority of criteria depends on the application that will use the
file
File Organization Types
The pile
The
The direct, sequential
or hashed, file
file
Five of the
common file
organizations are: The
The indexed
indexed sequential
file file
The Pile
■ Least complicated form
of file organization
■ Data are collected in
the order they arrive
■ Each record consists of
one burst of data
■ Purpose is simply to
accumulate the mass
of data and save it
■ Record access is by
exhaustive search
Indexed
Sequential File
■ Adds an index to the
file to support
random access
■ Adds an overflow file
■ Greatly reduces the
time required to
access a single record
■ Multiple levels of
indexing can be used
to provide greater
efficiency in access
The
Sequential
File
■ Most common form of
file structure
■ A fixed format is used
for records
■ Key field uniquely
identifies the record
■ Typically used in batch
applications
■ Only organization that is
easily stored on tape as
well as disk
Indexed File
■ Records are accessed only
through their indexes
■ Variable-length records can be
employed
■ Exhaustive index contains one
entry for every record in the
main file
■ Partial index contains entries to
records where the field of
interest exists
■ Used mostly in applications
where timeliness of information
is critical
■ Examples would be airline
reservation systems and
inventory control systems
Direct or Hashed File
■ Access directly any block of a known
address
■ Makes use of hashing on the key
value Examples are:
■ Often used where:
• directories
■ very rapid access is required
• pricing tables
■ fixed-length records are used
• schedules
■ records are always accessed
• name lists
one at a time
Operations Performed
on a Directory
■ To understand the requirements for a file structure, it is
helpful to consider the types of operations that may be
performed on the directory:
Create Delete List Update
Search
files files directory directory
Two-Level Scheme
Master directory has
There is one an entry for each Each user
directory for each user directory directory is a
user and a master providing address simple list of the
directory and access control files of that user
information
Names must be File system can
unique only within easily enforce access
the collection of files restriction on
of a single user directories
Figure 12.4
Tree-
Structured
Directory
■ Master
directory with
user directories
underneath it
■ Each user
directory may
have
subdirectories
and files as
entries
Figure 12.7
Example of
Tree-
Structured
Directory
File Sharing
Two issues arise
when allowing files
to be shared
among a number
of users:
management of
access rights simultaneous
access
Access
Rights
■ None ■ Appending
■ the user would not be allowed
to read the user directory that ■ the user can add data to the
includes the file file but cannot modify or
delete any of the file’s
■ Knowledge contents
■ the user can determine that
the file exists and who its
■ Updating
owner is and can then petition ■ the user can modify, delete,
the owner for additional access and add to the file’s data
rights
■ Execution ■ Changing protection
■ the user can load and execute ■ the user can change the
a program but cannot copy it access rights granted to
■ Reading
other users
■ the user can read the file for ■ Deletion
any purpose, including copying
and execution
■ the user can delete the file
from the file system
User Access Rights
Specifi User
Owner All
c Users Groups
usually the all users who
initial creator have access
of the file to this
individual a set of
system
users who users who
has full rights are are not
designated individually
by user ID defined
may grant these are
rights to public files
others