0% found this document useful (0 votes)
14 views35 pages

Lecture 37-39

Uploaded by

soomrokazim909
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)
14 views35 pages

Lecture 37-39

Uploaded by

soomrokazim909
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/ 35

Operating Systems

Concepts
LECTURE 37-39 – FILE MANAGEMENT
Files

 Files are the central element to most applications


 The File System is one of the most important part of the OS to a user
 Desirable properties of files:
 Long-term existence
 Sharable between processes
 Structure
File Management

 File management system consists of system utility programs that run as


privileged applications
 Concerned with secondary storage
Typical Operations

 File systems also provide functions which can be performed on files,


typically:
 Create
 Delete
 Open
 Close
 Read
 Write
Terms

 Field
 Basic element of data
 Contains a single value
 Characterized by its length and data type
 Record
 Collection of related fields
 Treated as a unit
 File
 Have file names
 Is a collection of similar records or collection of similar data or information
 Treated as a single entity
 May implement access control mechanisms
File System Software Architecture
File System Software Architecture
Contd.
 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
 Basic File System or Physical I/O
 Primary interface with the environment outside the computer system
 Deals with exchanging blocks of data
 Concerned with the placement of blocks
 Concerned with buffering blocks in main memory
File System Software Architecture
Contd.

 Basic I/O Supervisor


 Responsible for all file I/O initiation and termination.
 Control structures deal with Device I/O Scheduling and File Status
 Selects and schedules I/O with the device
 Logical I/O
 Enables users and applications to access records
 Provides general-purpose record I/O capability
 Maintains basic data about file
File System Software Architecture
Contd.

 Access Methods
 Closest to the user
 Reflect different file structures
 Provides a standard interface between applications and the file systems and
devices that hold the data
 Access method varies depending on the file structure
File Organization

 File Organization refers to the logical structure of records


 Physical organization discussed later
 Determined by the way in which files are accessed
Criteria for File Organization

 Important criteria include:


 Short access time
 Ease of update
 Economy of storage
 Simple maintenance
 Reliability
 Priority will differ depending on the use (e.g. read-only CD vs Hard Drive)
 e.g. if a file is only to be processed in batch mode, with all of the records accessed
every time, then rapid access for retrieval of a single record is of minimal concern.
 A file stored on CD-ROM will never be updated, and so ease of update is not an
issue.
File Organisation Types

 Many exist, but usually variations of:


 Pile
 Sequential file
 Indexed sequential file
 Indexed file
 Direct, or hashed, file
The Pile

 Data are collected in the order they arrive


 No structure
 Purpose is to accumulate a mass of data and
save it
 Records may have different fields
 Record access is by exhaustive search
 Pile files are encountered when data are
collected and stored before processing.
 This type of file is unsuitable for most
applications (Exhaustive Searches).
The Sequential File

 In this type of file a fixed format is used for records. All records are of fixed or same length
consisting of same number of fields of fixed length.
 One particular field usually the first field in each record is referred to as the Key field. It
uniquely identifies the record. The 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 numerical key.
 Sequential files are typically used in batch applications, involving the processing of all the
records (a billing or payroll application).
 For interactive applications that involve queries or update of individual records the sequential
file provides poor performance.
 A sequential file is stored in single sequential ordering of records with in blocks.
 The physical organization of the file on tape or disk directly matches the logical organization, in
the case the usual procedure is to place new records in a separate “Pile” file, called a log file or
transaction file.
 Periodically a batch update is performed that merges the log file with the master file to produce
a new file in correct sequence.
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
 The index provides a lookup capability to
reach quickly the vicinity of a desired record.
 and an overflow file, 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.
Indexed Sequential File Contd.

 The index in this case is a simple sequential file. Each record in the index file
consists of two fields, a key field, which is same as the key field in the main file,
and a pointer, into main file, to find a specific field, the index is searched to find
key value that is equal to the desired key value.
 The search continues in the main file at the location indicated by the pointer.
 Each record in the main file contains an additional field not visible to the
application, which is a pointer to the overflow file. When a new record is to be
inserted into the file it is added to the overflow file.
 The index sequential file greatly reduces the time required to access a single
record without sacrificing the sequential nature of the file.
Indexed File

 Uses multiple indexes for different key fields


 May contain an exhaustive index that contains one
entry for every record in the main file
 May contain a partial index
 When a new record is added to the main file, all of
the index files must be updated.
 Records are accessed only through their indexes.
 Now no restriction on the placement of records as long
as a pointer in at least one index refers to that record.
 Variable-length records can be employed.
Direct/Hashed File

 Exploits the capability found on disks to access directly any block of a


known address.
 The Direct or Hashed File
 The direct file makes use of hashing on the key value.
 Directly access a block at a known address using some mathematical
formula
 Key field required for each record
File Directory

 Collection of files associated with any file management system is file


directory.
 The directory contains information about the files, including attributes
locations and ownership, much of this information especially that
concerned with storage is managed by the O/S.
 The directory itself is a file owned by the O/S and accessible by various
file management routines.
 From the user’s point of view the directory provides a mapping between
file name that are known to users and applications and files themselves
 Typically owner of the file may grant access to other users.
ELEMENTS OF A FILE
DIRECTORY

 Basic Information
 Address Information
 Access Control Information
 Usage Information
Directory Elements:
Basic Information

 File Name
 Name as chosen by creator be unique with in a directory
 File Type
 Text file, Binary file
 File Organization
 For systems that support different file organizations.
Directory Elements:
Address Information

 Volume
 Indicate device on which file is stored.
 Starting Address
 Starting physical address on secondary storage for example cylinder track
and block number on disk.
 Size Used
 Current size of the file in bytes, words or blocks.
 Size Allocated
 The maximum size of the file.
Directory Elements:
Access Control Information

 Owner
 The owner may be able to grant/deny access to other users and to change
these privileges.
 Access Information
 May include the user’s name and password for each authorized user.
 Permitted Actions
 Controls reading, writing, executing, transmitting over a network
Directory Elements:
Usage Information

 Date Created
 Identity of Creator
 Date Last Read Access
 Identity of Last Reader
 Date Last Modified
 Identity of Last Modifier
 Date of Last Backup
 Current Usage
 Current activity, locks, etc
Structure for a Directory

 The method for storing the previous information varies


widely between systems
 Universally adopted approach is to use a Hierarchical
or Tree Structure
 Master directory with user directories underneath it
 Each user directory may have subdirectories and files
as entries
Example of
Tree-Structured Directory
Operations Performed on a Directory

 A directory system should support a number of operations including:


 Search
 Create files
 Deleting files
 Listing directory
 Updating directory
Naming

 Users need to be able to refer to a file by name


 Files need to be named uniquely, but users may not be aware of all filenames
on a system
 The tree structure allows users to find a file by following the directory
path
 Duplicate filenames are possible if they have different pathnames
File Sharing

 In multiuser system, allow files to be shared among users


 Two issues
 Access rights
 Management of simultaneous access
Access Rights

 A wide variety of access rights have been used by various systems


 often as a hierarchy where one right implies previous
 None
 User may not even know of the files existence
 Knowledge
 User can only determine that the file exists and who its owner is
Access Rights cont…

 Execution
 The user can load and execute a program but cannot copy it
 Reading
 The user can read the file for any purpose, including copying and execution
 Appending
 The user can add data to the file but cannot modify or delete any of the file’s
contents
Access Rights cont…

 Updating
 The user can modify, delete, and add to the file’s data.
 Changing protection
 User can change access rights granted to other users
 Deletion
 User can delete the file
User Classes

 Owner
 Usually the files creator, usually has full rights
 Specific Users
 Rights may be explicitly granted to specific users
 User Groups
 A set of users identified as a group
 All
 everyone
Simultaneous Access

 User may lock entire file when it is to be updated


 User may lock the individual records during the update
 Mutual exclusion and deadlock are issues for shared access
Thank You!

You might also like