0% found this document useful (0 votes)
58 views37 pages

Chapter 3

The document discusses file management techniques in operating systems. It describes five basic functions of a file system including storing files orderly, accessing stored files, appending files, and protecting files from data loss. It then explains three common file access techniques (sequential, direct, and indexed sequential access), and covers directory structures, file allocation methods, and free space management techniques using free lists and bitmaps.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views37 pages

Chapter 3

The document discusses file management techniques in operating systems. It describes five basic functions of a file system including storing files orderly, accessing stored files, appending files, and protecting files from data loss. It then explains three common file access techniques (sequential, direct, and indexed sequential access), and covers directory structures, file allocation methods, and free space management techniques using free lists and bitmaps.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

DFC 10103

OPERATING SYSTEM

Chapter 3: FILE MANAGEMENT


Learning outcome:

By the end of this lecture, students will be able


to:
1) Identify basic function of file system
2) Describe file access techniques
3) Describe the directory structure
4) Describe various methods of file allocation
5) Describe the two free space management
techniques
File Management : Introduction
• File management system can be define as a system that an
operating system uses to keep track of different files.
• Unlike the CPU and memory management aspects of the
operating system which aim mainly towards an optimum use
of the CPU, file management aims to provide a convenient
programming environment for the users of the system.
• There are several functions that must be performed by an
efficient file system:
 include storing of files in an orderly fashion
 accessing the stored files
 appending the stored files and protecting the files from loss of data
File Access Techniques

• Concerned with how records are arranged &


characteristics of medium used to store it.
• On magnetic disks, files can be organized as:
1) Sequential
2) Direct
3) Indexed sequential
1) Sequential

• Easiest to implement because records are stored &


retrieved serially, one after other.
• To speed process some optimization features may be
built into system.
• E.g., select a key field from record & then sort records by
that field before storing them.
• Aids search process.
• Complicates maintenance algorithms because original order
must be preserved every time records added or deleted.
2) Direct

• Uses direct access files which can be implemented only on


direct access storage devices.
• Give users flexibility of accessing any record in any order
without having to begin search from beginning of file.
• Records are identified by their relative addresses (their
addresses relative to beginning of file).
• Logical addresses computed when records are stored & again
when records are retrieved.
• Use hashing algorithms
• Advantages:
1)Fast access to records.
2)Can be updated more quickly than sequential files because
records quickly rewritten to original addresses after
modifications

• Disadvantage:
1)Several records with unique keys may generate same logical
address (collision)
3) Indexed sequential

• Combines best of sequential & direct access.


• Created & maintained through Indexed Sequential Access Method
(ISAM) software package.
• Doesn’t create collisions because it doesn’t use result of hashing
algorithm to generate a record’s address.
• Uses info to generate index file through which records retrieved.
• Divides ordered sequential file into blocks of equal size.
• Size determined by File Manager to take advantage of physical storage devices &
to optimize retrieval strategies.
• Each entry in index file contains highest record key & physical
location of data block where this record, & records with smaller
keys, are stored.
Directory Structure in File
Management
• In computing, a directory structure is the way
an operating system's file system and its files are
displayed to the user. Files are typically
displayed in a hierarchical tree structure.
Directory Structure

• 1. Storage Structure
• Each extent points to next one in sequence
• Directory entry
• Filename, storage location of first extent, location of last
extent, total number of extents (not counting first)

• 2. Directory Structure
• Each extent listed with physical address, size, pointer to next
extent
• Null pointer indicates last one
Cont…

• 3. Single-level Directory

• 4. Two-level Directory
Advantage of Single-level
Directory and Two-level Directory
Single-level Directory Two-level Directory

1. Simple structure 1. Solves the name collision


  problem
- difference user may have
same files names
2. All file in same category 2. Effective isolation of one
  user from others
3. Easy to support and 3. Efficient searching
understand
 
Methods of file allocation

• File manager works with files


• As whole units
• As logical units or records
• Within file
• Records must have same format
• Record length may vary
• Records subdivided into fields
• Application programs manage record structure
Methods of storing files

• Contiguous file allocation

• Linked list non-contiguous (disk blocks)/ Linked file


allocation

• Linked list non-contiguous (using index)/ Indexed file


allocation
1. Contiguous file allocation
• Each file occupies a set of contiguous blocks on the disk.

• Advantages:
 Simple – only starting location (block #) and length (number of
blocks) are required
 Random access – faster data reading

• Disadvantages:
 Wasteful of space – disk defragmentation
 Files cannot grow.
Contiguous file allocation
(cont..)
2. Linked list non-contiguous (using
blocks)/ Linked file allocation

• Each file is a linked list of disk blocks: blocks may


be scattered anywhere on the disk.
block = pointer
Linked list non-contiguous
(using blocks)/ Linked file allocation

• Advantages:
 Simple – need only starting address
 Free-space management system – no waste of space

• Disadvantages:
 Random access is slow
 Mapping – if the link is lost rest of the file can’t be
located
Linked list non-contiguous
(disk blocks)
3. Linked list non-contiguous
(using index-node)
• Index node is associated with each file
• Given an index node it’s possible to find all blocks of the
file
• Index nodes are fixed in size
• Logical view.
Linked list non-contiguous
(using index-node)
• Advantages:
 When a file is open only the corresponding index node
should be in memory
 Random access

• Disadvantages:
 Need index table
Example of Indexed Allocation
3) Linked list non-contiguous allocation
(using index)

• Allows direct record access


• Brings pointers together
• Links every extent file into index block
• Every file has own index block
• Disk sector addresses for file
• Lists entry in order sectors linked
• Supports sequential and direct access
• Does not necessarily improve storage space use
• Larger files experience several index levels
Free Space Management
Techniques
We need a way to keep track of space currently free. This
information is needed when we want to create or add (allocate) to
a file. When a file is deleted, we need to show what space is freed
up.

• 1. USING FREE LISTS


• Free blocks are chained together or linked list, each holding a pointer to the
next one free.

• This is very inefficient since a disk access is required to look at each sector.
Example Using Free Lists
Free Space Management
Techniques
• 2. USING BITMAPS
•  Each block is represented by a bit
• free space = bit 1
• allocate/occupied = bit 0

0 0 1 1 0 0 1 means blocks 2, 3, 6 are free.

• This method allows an easy way of finding contiguous free blocks.


Requires the overhead of disk space to hold the bitmap
Example Using Bitmaps
Types Of Operations in File
Protection
• 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.

• Execute: Allows or denies running program


(executable) files.
• Append: Allows or denies making changes to the end of the
file but not changing, deleting, or overwriting existing data.
• Delete: A file is removed from the file structure and
destroyed.
• List: List Folder allows or denies viewing file names and
subfolder names within the folder. List Folder only affects
the contents of that folder and does not affect whether the
folder you are setting the permission on will be listed.
Applies to folders only.
Access Control Matrix

• In a system with multiple users, it’s important to


protect one user’s objects (files, directories) from
other users.
• Two levels of protections:
• Logon verifications: guarantees you have the right to log onto the
system
• Access determination: guarantees you have permission to access a
specific object

• Access matrix, access lists, capability lists: techniques


for determining access rights.
 The basic elements are:
 subject – an entity capable of accessing objects
 object – anything to which access is controlled
 access right – the way in which an object is accessed by a subject
 The basic elements are:
 subject – an entity capable of accessing objects
 object – anything to which access is controlled
 access right – the way in which an object is accessed by a subject
Access
Control Lists

• A matrix may be
decomposed by columns,
yielding access control
lists
• The access control list
lists users and their
permitted access rights
Capability
Lists

• Decomposition
by rows yields
capability tickets
• A capability
ticket specifies
authorized
objects and
operations for a
user
Techniques Used To Prevent
Data Loss
• A backup is a copy of data from your raw device that
can be used to reconstruct that data. Backups can be
divided into physical backups and logical backups.

• PHYSICAL BACKUPS
• Physical backups is the movement of all data : used in storing
and recovering data from one raw device to another, in the
context of file system backup the source devices are disks and
destination devices may include disk, CD-ROM, floppy, ZIP
devices and tape.
Cont..Physical Backups
• Benefits:
• Simplicity – every bit from the source device is copied to the destination; the
format of the data is irrelevant to the backup procedure
• Fast speed – it is able to order the access to the media in whatever way is most
efficient

• Weaknesses:
• Necessary to restore the file system to disks that are the same size and
configuration as the originals
• Restoring a subset(single file which was accidently deleted is not very practical
• The file system must not be changing when the backup is performed
Logical Backups
• LOGICAL BACKUPS
• Logical backups contain logical data (for example, tables or stored
procedures) exported from a disk with the utility and stored in a binary file

• Benefits:
• User can backup a subset of a data in a file system which can save time
and media space
• If a user accidentally deletes a file, a logical restore can locate the file on
tape, and restore only that file

• Weaknesses:
• Only a person with root access to the filter can run restore

You might also like