File Management

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

FILE MANAGEMENT

CHAPETER 8
The File manager

• The File Manager (also called the file management system) is the
software responsible for creating, deleting, modifying, and
controlling access to files—as well as for managing the resources
used by the file.
Responsibilities of the File Manager
1. Keep track of where each file is stored.
2. Use a policy that will determine where and how the files will be stored,
making sure to efficiently use the available storage space and provide efficient
access to the files.
3. Allocate each file when a user has been cleared for access to it, then record
its use.
4. Deallocate the file when the file is to be returned to storage, and
communicate its availability to others who may be waiting for it
In a computer system, the File Manager keeps track of its files with
directories that contain the filename, its physical location in secondary
storage, and important information about each file
The computer system allocates a file by activating the appropriate
secondary storage device and loading the file into memory while updating its
records of who is using what file. Finally, the File Manager deallocates a file by
updating the file tables and rewriting the file (if revised) to the secondary
storage device. Any processes waiting to access the file are then notified of its
availability
• A field is a group of related bytes that can be identified by the user with a name, type, and size.
• A record is a group of related fields.
• A file is a group of related records that contains information to be used by specific application
programs to generate reports.
• A database appears to the File Manager to be a type of file, but databases are more complex
because they’re actually groups of related files that are interconnected at various levels to give users
flexibility of access to the data stored.
• Program files contain instructions and data files contain data; but as far as storage is concerned, the
File Manager treats them exactly the same way.
• Directories are special files with listings of filenames and their attributes.
Interacting With The File Manager

• Users communicates with File Manger via specific commands.


• CREATE & DELETE – deal with the system’s knowledge of file.
• SAVE – first time used, a file is actually created.
• OPEN NEW – within a program indicates file must be created.
• RENAME – allows users to change name of the existing file
• COPY – allows user to make duplicate copies of existing files.
Typical Volume Configuration

• Each secondary storage unit, whether it’s removable or not, is


considered a volume.
• Each volume can contain several files called multifile volumes.
• Some files are extremely large and are contained in several volumes
called multivolume files.
• Generally, each volume in system is given name.
• File Manager writes name and other descriptive info on easy-to-access
place on each unit.
Volume Descriptor
Master File Directory (MFD)

• MFD is stored immediately after volume descriptor


• Lists names and characteristics of every file contained in volume.
• File names refer to program files, data files, and/or system files.
• Subdirectories are listed in the MFD if supported.
• The remainder of the volume is used for file storage.

• Early OS supported only a single directory per volume.


• Created by File Manager
• Contains names of files, usually organized in alphabetical, spatial or chronological order.
• Simple to implement and maintain.
Some Major Disadvantages of Single Directory
Per Volume
1. Takes long time to search for an individual file, especially if MFD was organized in an arbitrary
order.
2. If user has many small files stored in volume, directory space fills before disk storage space
fills. User told “disc full” when only directory full.
3. Users can’t create subdirectories to group related files.
4. Multiple users can’t safeguard files from other users browsing file lists because entire directory
was freely made available to every user in the group on request.
5. Each program in entire directory needs unique name, even those directories serving many users,
so only one person using that directory could have a program named Program1.
Introducing Subdirectories

• File Managers create an MFD for each volume that can contain entries for
both files and subdirectories. A subdirectory is created when a user opens an
account to access the computer system.
• Each file entry in every directory contains information describing the file; it’s
called the file descriptor.
Information typically included in a file descriptor includes the following:

• Filename—within a single directory, filenames must be unique; in some operating


systems, the filenames are case sensitive
• File type—the organization and usage that are dependent on the system (for
example, files and directories)
• File size—although it could be computed from other information, the size is kept here
for convenience
• File location—identification of the first physical block (or all blocks) where the file is
stored
• Date and time of creation
• Owner
• • Protection information—access restrictions, based on who is allowed to access the
file and what type of access is allowed
• • Record size—its fixed size or its maximum size, depending on the type of record
File-Naming Conventions
• A file’s name can be much longer than it appears. Depending on the File
Manager, it can have from two to many components. The two components
common to many filenames are a relative filename and an extension.
File Complete Name in different operating
system.

Windows operating system:


C:\IMFST\FLYNN\INVENTORY_COST.DOC

Linux:
/usr/imfst/flynn/inventory_cost.doc
FILE ORGANIZATION

Arrangement of records within a file because all files are composed of


records. When a user gives a command to modify the contents of a file, it’s
actually a command to access records within the file.
Record Format
Fig. 8.6
When data is stored in Fixed-Length field, data that extends beyond the fixed size is truncated.
All the records in the file are of same size; leads to memory wastage; access of the records is easier
and faster.

When data is stored in Variable-Length record format, the size expands to fit the contents
but it takes longer to access it. Different records in the file have different sizes; memory efficient;
access of the records is slower.
File organization refers to the
relationship of the key of the record
to the physical location of that
record in the computer file. File
organization may be either physical
file or a logical file. A physical file is
a physical unit, such as magnetic
tape or a disk.
Types of
File Organizations 

• Sequential File Organization.
Heap File Organization.
Hash File Organization.
B+ Tree File Organization.
Clustered FileOrganization.
• Sequential File Organization
• A sequential file contains records organized by the
order in which they were entered. The order of the
records is fixed. Records in sequential files can be read
or written only sequentially. After you place a record
into a sequential file, you cannot shorten, lengthen, or
delete the record.
Heap File Organization.
• It is the simplest and most basic type of organization. It works
with data blocks. In heap file organization, the records are
inserted at the file's end. When the records are inserted, it
doesn't require the sorting and ordering of records.
• Hash File Organization.
• Hash File Organization uses the computation of hash function on
some fields of the records. The hash function's output determines the
location of disk block where the records are to be placed.
B+ Tree File Organization
• B+ tree file organization is the advanced method of an
indexed sequential access method. It uses a tree-like
structure to store records in File.
• The B+ tree is similar to a binary search tree (BST), but it
can have more than two children. In this method, all the
records are stored only at the leaf node. Intermediate nodes
act as a pointer to the leaf nodes. They do not contain any
records.
Clustered FileOrganization.
• The cluster file organization is used when there is a frequent need
for joining the tables with the same condition. These joins will give
only a few records from both tables. In the given example, we are
retrieving the record for only particular departments. This method
can't be used to retrieve the record for the entire department.

You might also like