A LOverview
• File Organization and Access
• File Directories
• File Sharing
File Management
File management in operating system is a software that handles
or manages the files (binary, text, pdf, docs, audio, video,
etc.) present in computer software.
• The file system in the operating system is capable of managing
individual as well as groups of files present in the computer
system.
• The file system provides the mechanism for on-line storage of
and access to both data and programs of the operating
system and all the users.
• The file system consists of two distinct parts: a collection of
files, each storing related data, and a directory structure,
which organizes and provides information about all the files in
the system.
File Management
• A file is a named collection of related information that is
recorded on secondary storage.
• A file is the smallest allotment of logical secondary storage;
that is, data cannot be written to secondary storage unless
they are within a file.
• Commonly, files represent programs (both source and object
forms) and data.
• Data files may be numeric, alphabetic, alphanumeric, or binary.
• Files may be free form, such as text files, or may be formatted
rigidly.
• A file is a sequence of bits, bytes, lines, or records, the
meaning of which is defined by the file's creator and user.
File Management
File Management
The file system permits users to create data collections, called
files, with desirable properties, such as:
• 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: Depending on the file system, a file can have an
internal structure that is convenient for particular
applications. In addition, files can be organized into
hierarchical or more complex structure to reflect the
relationships among files.
File Operations
Any file system provides not only a means to store data organized as
files, but a collection of functions that can be performed on files.
Typical operations include the following:
• Create: A new file is defined and positioned within the structure of
files.
• Delete: A file is removed from the file structure and destroyed. •
Open: An existing file is declared to be “opened” by a process,
allowing the process to perform functions on the file.
• Close: The file is closed with respect to a process, so that the
process no longer may perform functions on the file, until the process
opens the file again.
• Read: A process reads all or a portion of the data in a file. • Write: A
process updates a file, either by adding new data that expands the size
of the file or by changing the values of existing data items in the file.
File Structure
File Structure
Four terms are in common use when discussing
files: ▪ Field
▪ Record
▪ File
▪ Database
• A field is the basic element of data. An individual field contains
a single value, such as an employee’s last name, a date, or the
value of a sensor reading. It is characterized by its length and
data type (e.g., ASCII string, decimal).
• Depending on the file design, fields may be fixed length or
variable length.
• In the latter case, the field often consists of two or three
subfields: the actual value to be stored, the name of the field,
and, in some cases, the length of the field.
File Structure
• A record is a collection of related fields that can be treated as a
unit by some application program.
• For example, an employee record would contain such fields as
name, social security number, job classification, date of hire,
and so on.
• Depending on design, records may be of fixed length or
variable length.
• A file is a collection of similar records. The file is treated as a
single entity by users and applications and may be referenced
by name.
• Files have file names and may be created and deleted.
File Structure
• A database is a collection of related data. The essential aspects
of a database are that the relationships that exist among
elements of data are explicit and that the database is
designed for use by a number of different applications.
• A database may contain all of the information related to an
organization or project, such as a business or a scientific
study.
• The database itself consists of one or more types of files. •
Usually, there is a separate database management system that is
independent of the operating system, although that system may
make use of some file management programs
Fil
e Management Systems
A file management system is that set of system software that provides
services to users and applications in the use of files.
Objectives for a file management system:
• To meet the data management needs and requirements of the
user, which include storage of data and the ability to perform the
aforementioned operations
• To guarantee, to the extent possible, that the data in the file are
valid
• To optimize performance, both from the system point of view in
terms of overall throughput and from the user’s point of view in
terms of response time
• To provide I/O support for a variety of storage device types • To
minimize or eliminate the potential for lost or destroyed data • To
provide a standardized set of I/O interface routines to user
processes
• To provide I/O support for multiple users, in the case of multiple
user systems
File Management Systems
Depending on the variety of applications and the environment in
which the computer system will be used. For an interactive,
general-purpose system, the following constitute a minimal set of
requirements:
1. Each user should be able to create, delete, read, write, and modify
files.
2. Each user may have controlled access to other users’ files. 3. Each
user may control what types of accesses are allowed to the user’s files.
4. Each user should be able to restructure the user’s files in a form
appropriate to the problem.
5. Each user should be able to move data between files. 6. Each user
should be able to back up and recover the user’s files in case of
damage.
7. Each user should be able to access his or her files by name rather
than by numeric identifier.
FILE SYSTEM ARCHITECTURE
• At the lowest level, device drivers communicate
directly with peripheral devices or their controllers or
channels. • A device driver is responsible for starting I/O
operations on a device and processing the completion of
an I/O request. • For file operations, the typical devices
controlled are disk and tape drives.
• Device drivers are usually considered to be part of the
operating system.
FILE SYSTEM ARCHITECTURE
The basic I/O supervisor is responsible for all file I/O initiation
and termination.
• At this level, control structures are maintained that deal
with device I/O, scheduling, and file status.
• The basic I/O supervisor selects the device on which file I/O
is to be performed, based on the particular file selected. • It
is also concerned with scheduling disk and tape accesses to
optimize performance.
• I/O buffers are assigned and secondary memory is allocated
at this level.
• The basic I/O supervisor is part of the operating system.
Logical I/O enables users and applications to access records. •
The basic file system deals with blocks of data, the logical I/O
module deals with file records.
• Logical I/O provides a general-purpose record I/O capability
and maintains basic data about files.
FILE SYSTEM ARCHITECTURE
The level of the file system closest to the user is often termed
the access method.
• It provides a standard interface between applications and
the file systems and devices that hold the data.
• Users and application programs interact with the file system by
means of commands for creating and deleting files and for
performing operations on files.
• Before performing any operation, the file system must identify
and locate the selected file. This requires the use of some sort
of directory that serves to describe the location of all files,
plus their attributes.
• Most shared systems enforce user access control: Only
authorized users are allowed to access particular files in
particular ways.
• The basic operations that a user or application may perform on
a file are performed at the record level.
• The user or application views the file as having some structure
that organizes the records, such as a sequential structure
(e.g., personnel records are stored alphabetically by last
name).
FILE MANAGEMENT
FUNCTIONS
FILE MANAGEMENT FUNCTIONS
• To translate user commands into specific file manipulation
commands, the access method appropriate to this file
structure must be employed.
• Whereas users and applications are concerned with records or
fields, I/O is done on a block basis.
• Thus, the records or fields of a file must be organized as a
sequence of blocks for output and unblocked after input. • To
support block I/O of files, several functions are needed. The
secondary storage must be managed.
• This involves allocating files to free blocks on secondary
storage and managing free storage so as to know what blocks
are available for new files and growth in existing files.
FILE ORGANIZATION AND ACCESS
• File organization to refer to the logical structuring of the
records as determined by the way in which they are accessed. •
The physical organization of the file on secondary storage
depends on the blocking strategy and the file allocation strategy.
In choosing a file organization, several criteria are important:
• Short access time
• Ease of update
• Economy of storage
• Simple maintenance
• Reliability
FILE ORGANIZATION AND ACCESS
The five organizations are as follows:
• The pile
• The sequential file
• The indexed sequential file
• The indexed file
• The direct, or hashed file
The Pile
▪ The least-complicated form of file organization may be
termed the pile .
▪ Data are collected in the order in which they arrive. Each
record consists of one burst of data.
▪ The purpose of the pile is simply to accumulate the mass of
data and save it.
FILE ORGANIZATION AND
ACCESS The Sequential File
▪ In this type of file, a fixed format is used for records. ▪ All
records are of the same length, consisting of the same
number of fixed-length fields in a particular order. ▪ Because
the length and position of each field are known, only the
values of fields need to be stored; the field name and length
for each field are attributes of the file structure.
▪ One particular field, usually the first field in each record, is
referred to as the key field .
▪ The key field uniquely identifies the record; thus key values
for different records are always different.
▪ The records are stored in key sequence: alphabetical order
for a text key, and numerical order for a numerical key.
FILE ORGANIZATION AND ACCESS
The Indexed Sequential File
▪ A popular approach to overcoming the disadvantages of
the sequential file is the indexed sequential file.
▪ The indexed sequential file maintains the key characteristic
of the sequential file: Records are organized in sequence
based on a key field.
▪ Two features are added: an index to the file to support
random access, and an overflow file.
▪ The index provides a lookup capability to reach quickly the
vicinity of a desired record.
▪ The overflow file is similar to the log file used with a
sequential file but is integrated so that a record in the
overflow file is located by following a pointer from its
predecessor record.
FILE ORGANIZATION AND ACCESS
The Indexed File
▪ The indexed sequential file retains one limitation of the
sequential file: Effective processing is limited to that which
is based on a single field of the file.
▪ For example, when it is necessary to search for a record on
the basis of some other attribute than the key field, both
forms of sequential file are inadequate.
▪ In some applications, the flexibility of efficiently searching
by various attributes is desirable.
FILE ORGANIZATION AND ACCESS
The Direct or Hashed File
▪ The direct, or hashed, file exploits the capability found on
disks to access directly any block of a known address. As
with sequential and indexed sequential files, a key field is
required in each record. There is no concept of sequential
ordering here.
▪ The direct file makes use of hashing on the key value. ▪
Direct files are often used where very rapid access is
required, where fixed length records are used, and where
records are always accessed one at a time.
▪ Examples are directories, pricing tables, schedules, and
name lists.
File Directories
• Associated with any file management system and collection of
files is a file directory.
• The directory contains information about the files, including
attributes, location, and ownership.
• Much of this information, especially that concerned with
storage, is managed by the operating system.
• The directory is itself a file, accessible by various file
management routines.
• Although some of the information in directories is available to
users and applications, this is generally provided indirectly by
system routines.
File Directories
Structure
▪ The way in which the information is stored differs widely
among various systems.
▪ Some of the information may be stored in a header record
associated with the file; this reduces the amount of storage
required for the directory, making it easier to keep all or much
of the directory in main memory to improve speed.
▪ The simplest form of structure for a directory is that of a list of
entries, one for each file.
File Directories
Types of Operations that may be performed on the directory: •
Search: When a user or application references a file, the
directory must be searched to find the entry corresponding to
that file.
• Create file: When a new file is created, an entry must be
added to the directory.
• Delete file: When a file is deleted, an entry must be removed
from the directory.
• List directory: All or a portion of the directory may be
requested. Generally, this request is made by a user and results
in a listing of all files owned by that user, plus some of the
attributes of each file (e.g., type, access control information,
usage information).
• Update directory: Because some file attributes are stored in
the directory, a change in one of these attributes requires a
change in the corresponding directory entry.
File sharing
In a multiuser system, there is requirement for allowing files to
be shared among a number of users. Two issues arise: access
rights and the management of simultaneous access.
Access Rights
▪ The file system should provide a flexible tool for allowing
extensive file sharing among users.
▪ The file system should provide a number of options so that
the way in which a particular file is accessed can be
controlled.
▪ Typically, users or groups of users are granted certain
access rights to a file.
File sharing
The following list is representative of access rights that can be
assigned to a particular user for a particular file:
• None: The user may not even learn of the existence of the file, much
less access it. To enforce this restriction, the user would not be allowed
to read the user directory that includes this file.
• Knowledge: The user can determine that the file exists and who its
owner is. The user is then able to petition the owner for additional
access rights.
• Execution: The user can load and execute a program but cannot
copy it. Proprietary programs are often made accessible with this
restriction.
• Reading: The user can read the file for any purpose, including
copying and execution. Some systems are able to enforce a distinction
between viewing and copying. In the former case, the contents of the
file can be displayed to the user, but the user has no means for making
a copy.
File sharing
• Appending: The user can add data to the file, often only at the
end, but cannot modify or delete any of the file’s contents. This
right is useful in collecting data from a number of sources.
• Updating: The user can modify, delete, and add to the file’s
data. This normally includes writing the file initially, rewriting it
completely or in part, and removing all or a portion of the data.
Some systems distinguish among different degrees of updating.
• Changing protection: The user can change the access rights
granted to other users. Typically, this right is held only by the
owner of the file. In some systems, the owner can extend this
right to others. To prevent abuse of this mechanism, the file
owner will typically be able to specify which rights can be
changed by the holder of this right.
• Deletion: The user can delete the file from the file system.One
user is designated as owner of a given file, usually the person who
initially created a file. The owner has all of the access rights listed
previously and may grant rights to others.
Access can be provided to different classes of users:
• Specific user: Individual users who are designated by user ID
• User groups: A set of users who are not individually defined.
The system must have some way of keeping track of the
membership of user groups.
• All: All users who have access to this system. These are public
files.
File sharing
Simultaneous Access
▪ When access is granted to append or update a file to more
than one user, the operating system or file management
system must enforce discipline.
▪ A brute-force approach is to allow a user to lock the entire
file when it is to be updated.
▪ A finer grain of control is to lock individual records during
update.
File Management
Access Methods
Access Methods
Access Methods
Access Methods
Access Methods
Questions