You are on page 1of 45

File Management

Index
Definition of OS File and related terms Purpose of File Management Operations on File File Allocation Methods File Organization

Operating System
An operating system is software, consisting of programs and data, that runs on computers, manages computer hardware resources, and pro ides common ser ices for execution of arious application software! A program that acts as an intermediary "etween a user of a computer and the computer hardware!

Functions of OS
Process Management Memory Management I#O Management Secondary Storage Management File Management

$hat is File
A file is a collection of related information defined "y its creator! Files represent programs %"oth source and o"&ect forms' and data!

(aming )on ention


*he a"solute file name consists of+ dri e name directory name%s' file name ,xtension For example + d+#networ-#.A(!doc

Information structure of a file


/ the 0le1s type %plain 0le, directory, etc',

/ the 0le1s size, in "ytes and#or "loc-s, / any limits set on the 0le1s size, / the primary owner of the 0le, / information a"out other potential users of this 0le, / access constraints on the owner and other users, / dates and times of creation, last access and last modi0cation, / dates and times of last "ac-up and reco ery,

*erms 2sed with Files


Field
3asic element of data )ontains a single alue )haracterized "y its length and data type

4ecord
)ollection of related fields *reated as a unit
,xample+ employee record

*erms 2sed with Files


File
)ollection of similar records *reated as a single entity 5a e file names May restrict access

Data"ase
)ollection of related data 4elationships exist among elements

File Management
*he operating system is responsi"le for the following acti ities in connections with file management+ File creation and deletion! Directory creation and deletion! Support for manipulating files and directories! Mapping files onto secondary storage! File "ac-up on sta"le %non olatile' storage media!

File Management
/ Identify and locate a selected file / 2se a directory to descri"e the location of all files plus their attri"utes / On a shared system descri"e user access control / 3loc-ing for access to files / Allocate files to free "loc-s / Manage free storage for a aila"le "loc-s!

Purpose of File Management


*he file manager handles all files on secondary storage media! *o perform these tas-s, file management must+ "e a"le to identify the numerous files "y gi ing uni6ue names to them maintain a list telling where exactly each file is stored, how many sectors on the medium it occupies, and in which order those sectors ma-e up the file

Purpose of File Management


pro ide simple and fast algorithms to read and write files gi e and deny access rights on files to users and programs allocate and deallocate files to processes pro ide users and programs with simple commands for file handling

Minimal Set of 4e6uirements


,ach user should "e a"le to create, delete, read, write and modify files ,ach user may ha e controlled access to other users1 files ,ach user may control what type of accesses are allowed to the users1 files ,ach user should "e a"le to restructure the user1s files

Minimal Set of 4e6uirements


,ach user should "e a"le to mo e data "etween files ,ach user should "e a"le to "ac- up and reco er the user1s files in case of damage ,ach user should "e a"le to access the user1s files "y using sym"olic names

File Operations
)reate Delete Open )lose 4ead $rite

*ypical Operations
Retrieve_All + 4etrie e all the records of a file! *his operation will "e re6uired for an application that must process all the information in the file at one time! Retrieve_One + *his operation re6uires the retrie al of &ust a single record! Interacti e, transaction7oriented applications need this operation Retrieve_Next : *his operation re6uires the retrie al of the record that is 8next9 in some logical se6uence to the most recently recei ed record! for example + filling in forms

*ypical Operations
Retrieve_Previous : Similar to retrie e next, "ut in this case the record that is 8pre ious9 to the currently accessed record is retrie ed Insert_One : Insert a new record into the file! It may "e necessary that the new record fit into a particular position to preser e a se6uencing of the file! Delete_One : delete an existing record! )ertain lin-ages or other data structures may need to "e updated to preser e the se6uencing of the file!

*ypical Operations
Update_One : 4etrie e a record, update one or more of its fields, and rewrite updated record "ac- into the file! Retrieve_Few : 4etrie e a num"er of records! For example, an application may wish to retrie e all records that satisfy a certain set of criteria!

Access 4ights
(one 2ser may not -now of the existence of the file 2ser is not allowed to read the user directory that includes the file :nowledge 2ser can only determine that the file exists and who its owner is

Access 4ights
,xecution *he user can load and execute a program "ut cannot copy it 4eading *he user can read the file for any purpose, including copying and execution Appending *he user can add data to the file "ut

Access 4ights
2pdating *he user can modify, deleted, and add to the file1s data! *his includes creating the file, rewriting it, and remo ing all or part of the data )hanging protection 2ser can change access rights granted to other users Deletion 2ser can delete the file

Allocation Methods
contiguous file allocation chained allocation indexed allocation

Methods of File Allocation


Contiguous allocation Single set of "loc-s is allocated to a file at the time of creation Only a single entry in the file allocation ta"le % Starting "loc- and length of the file ' ,xternal fragmentation will occur (eed to perform compaction

Methods of File Allocation

Methods of File Allocation

Methods of File Allocation


Chained allocation Allocation on "asis of indi idual "loc ,ach "loc- contains a pointer to the next "loc- in the chain Only single entry in the file allocation ta"le Starting "loc- and length of file (o external fragmentation 3est for se6uential files

Methods of File Allocation

Methods of File Allocation

Methods of File Allocation


Indexed allocation File allocation ta"le contains a separate one7le el index for each file *he index has one entry for each portion allocated to the file *he file allocation ta"le contains "locnum"er for the index

Methods of File Allocation

File Organization
File Organization refers to the logical structuring of the records as determined "y the way in which they are accessed )riteria for File Organization + Short access time ,ase of update ,conomy of storage Simple maintenance 4elia"ility

File Organization
Fi e different types of File Organization a aila"le+ / *he pile / *he Se6uential file / *he Indexed Se6uential file / *he Indexed file / *he Direct or hashed file

File Organization
The Pile Data are collected in the order they arri e Purpose is to accumulate a mass of data and sa e it 4ecords may ha e different fields (o structure 4ecord access is "y exhausti e search

File Organization

File Organization
The Sequential File Fixed format used for records 4ecords are the same length All fields the same %order and length' Field names and lengths are attri"utes of the file One field is the -ey filed %Primary -ey'

File Organization
The Sequential File (ew records are placed in a log file or transaction file 3atch update is performed to merge the log file with the master file!

File Organization
Sequential File

)ontains -ey field and a pointer to the main file Search continues in the main file at the location indicated "y the pointer

File Organization
Indexed Sequential File (ew records are added to an o erflow file 4ecord in main file that precedes it is updated to contain a pointer to the new record *he o erflow is merged with the main file Multiple indexes for the same -ey field can "e set up to increase efficiency

File Organization

File Organization
Indexed File

2ses multiple indexes for different -ey fields May contain an exhausti e index that contains one entry for e ery record in the main file May contain a partial index

File Organization

File Organization
The Direct or Hashed File

Directly access a "loc- at a -nown address :ey field re6uired for each record

File Sharing
In multiuser system, allow files to "e shared among users *wo issues Access rights Management of simultaneous access

*han-s

You might also like