Lecture 10 File Management
Lecture 10 File Management
Systems:
Internals
and
Design Lecture 10
Principles File Management
By Joram M. Makasa
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
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
• should be able to access his or her files by name rather than by numeric identifier
7
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 record
and I/O capability Maintains
applications to basic data
access records about file
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
Identify and
locate the Records
selected as
file Appropriate to
the file
structure
Priority of criteria depends on the application that will use the file
File Organization Types
The pile
The
The direct, or sequential file
hashed, file
The indexed
The indexed
sequential file
file
The Pile
Least complicated form of
file organization
Purpose is simply to
accumulate the mass of data
and save it
Record access is by
exhaustive search
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
Sequential File
Adds an index to the file to
support random access
Information
Elements of a
File Directory
Names must be
Each user directory
unique only within
is a simple list of
the collection of files
the files of that user of a single user
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 includes the user can add data to the file
the file but cannot modify or delete any
of the file’s contents
Knowledge
the user can determine that the file Updating
exists and who its owner is and can
then petition the owner for
the user can modify, delete, and
additional access rights add to the file’s data
Execution Changing protection
the user can load and execute a the user can change the access
program but cannot copy it rights granted to other users
Reading
Deletion
the user can read the file for any
purpose, including copying and the user can delete the file from
execution the file system
User Access Rights
The approach taken for file allocation may influence the approach taken
for free space management
Blocks
Variable, large contiguous • small fixed portions provide
portions greater flexibility
• provides better performance • they may require large tables
• the variable size avoids or complex structures for
waste their allocation
• the file allocation tables are • contiguity has been
small abandoned as a primary goal
• blocks are allocated as needed
Table 12.2
File Allocation Methods
Free Space Management
Just as allocated space must be managed, so must the unallocated space
To perform file allocation, it is necessary to know which blocks are
available
A disk allocation table is needed in addition to a file allocation table
Bit Tables
This method uses a vector containing one bit for each block on the disk
Each entry of a 0 corresponds to a free block, and each 1 corresponds to
a block in use
Advantages:
•works well with any file allocation method
•it is as small as possible
Chained Free Portions
The free portions may be chained together by using a pointer and length
value in each free portion
Negligible space overhead because there is no need for a disk allocation
table
Suited to all file allocation methods
Disadvantages:
•leads to fragmentation
•every time you allocate a block you need to read the block first to recover the pointer to the new first free block before writing data to that block
Indexing
Treats free space as a file and uses an index table as it would for file
allocation
For efficiency, the index should be on the basis of variable-size
portions rather than blocks
This approach provides efficient support for all of the file allocation
methods
Free Block List