470 likes | 843 Views
Topic : File Management. Lecture By : Rupinder Kaur Lect IT,SRSGPCG Ludhiana. Index. Definition of OS File and related terms Purpose of File Management Operations on File File Allocation Methods File Organization. Operating System.
E N D
Topic : File Management Lecture By : Rupinder Kaur Lect IT,SRSGPCG Ludhiana
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 provides common services for execution of various application software. • A program that acts as an intermediary between a user of a computer and the computer hardware.
Functions of OS • Process Management • Memory Management • I/O Management • Secondary Storage Management • File Management
What is File • A file is a collection of related information defined by its creator. • Files represent programs (both source and object forms) and data.
Naming Convention The absolute file name consists of: • drive name • directory name(s) • file name • Extension For example : d:/network/LAN.doc
Information structure of a file • the file’s type (plain file, directory, etc), • the file’s size, in bytes and/or blocks, • any limits set on the file’s size, • the primary owner of the file, • information about other potential users of this file, • access constraints on the owner and other users, • dates and times of creation, last access and last modification, • dates and times of last backup and recovery, and • event triggers when the file changes
Terms Used with Files • 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 • Example: employee record
Terms Used with Files • File • Collection of similar records • Treated as a single entity • Have file names • May restrict access • Database • Collection of related data • Relationships exist among elements
File Management • The operating system is responsible for the following activities 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 backup on stable (nonvolatile) storage media.
File Management • Identify and locate a selected file • Use a directory to describe the location of all files plus their attributes • On a shared system describe user access control • Blocking for access to files • Allocate files to free blocks • Manage free storage for available blocks.
Purpose of File Management The file manager handles all files on secondary storage media. To perform these tasks, file management must: • be able to identify the numerous files by giving unique 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 make up the file
Purpose of File Management • provide simple and fast algorithms to read and write files • give and deny access rights on files to users and programs • allocate and deallocate files to processes • provide users and programs with simple commands for file handling
Minimal Set of Requirements • Each user should be able to create, delete, read, write and modify files • Each user may have controlled access to other users’ files • Each user may control what type of accesses are allowed to the users’ files • Each user should be able to restructure the user’s files
Minimal Set of Requirements • Each user should be able to move data between files • Each user should be able to back up and recover the user’s files in case of damage • Each user should be able to access the user’s files by using symbolic names
File Operations • Create • Delete • Open • Close • Read • Write
Typical Operations • Retrieve_All : Retrieve all the records of a file. This operation will be required for an application that must process all the information in the file at one time. • Retrieve_One : This operation requires the retrieval of just a single record. Interactive, transaction-oriented applications need this operation • Retrieve_Next : This operation requires the retrieval of the record that is “next” in some logical sequence to the most recently received record. for example : filling in forms
Typical Operations • Retrieve_Previous : Similar to retrieve next, but in this case the record that is “previous” to the currently accessed record is retrieved • Insert_One : Insert a new record into the file. It may be necessary that the new record fit into a particular position to preserve a sequencing of the file. • Delete_One : delete an existing record. Certain linkages or other data structures may need to be updated to preserve the sequencing of the file.
Typical Operations • Update_One : Retrieve a record, update one or more of its fields, and rewrite updated record back into the file. • Retrieve_Few : Retrieve a number of records. For example, an application may wish to retrieve all records that satisfy a certain set of criteria.
Access Rights • None • User may not know of the existence of the file • User is not allowed to read the user directory that includes the file • Knowledge • User can only determine that the file exists and who its owner is
Access Rights • 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 • Updating • The user can modify, deleted, and add to the file’s data. This includes creating the file, rewriting it, and removing all or part of the data • Changing protection • User can change access rights granted to other users • Deletion • User can delete the file
Allocation Methods • contiguous file allocation • chained allocation • indexed allocation
Methods of File Allocation Contiguous allocation • Single set of blocks is allocated to a file at the time of creation • Only a single entry in the file allocation table ( Starting block and length of the file ) • External fragmentation will occur • Need to perform compaction
Methods of File Allocation Chained allocation • Allocation on basis of individual block • Each block contains a pointer to the next block in the chain • Only single entry in the file allocation table • Starting block and length of file • No external fragmentation • Best for sequential files
Methods of File Allocation Indexed allocation • File allocation table contains a separate one-level index for each file • The index has one entry for each portion allocated to the file • The file allocation table contains block number for the index
File Organization File Organization refers to the logical structuring of the records as determined by the way in which they are accessed Criteria for File Organization : • Short access time • Ease of update • Economy of storage • Simple maintenance • Reliability
File Organization Five different types of File Organization available: • The pile • The Sequential file • The Indexed Sequential file • The Indexed file • The Direct or hashed file
File Organization The Pile • Data are collected in the order they arrive • Purpose is to accumulate a mass of data and save it • Records may have different fields • No structure • Record access is by exhaustive search
File Organization The Sequential File • Fixed format used for records • Records are the same length • All fields the same (order and length) • Field names and lengths are attributes of the file • One field is the key filed (Primary key)
File Organization The Sequential File • New records are placed in a log file or transaction file • Batch update is performed to merge the log file with the master file.
File Organization • Sequential File • Contains key field and a pointer to the main file • Search continues in the main file at the location indicated by the pointer
File Organization Indexed Sequential File • New records are added to an overflow file • Record in main file that precedes it is updated to contain a pointer to the new record • The overflow is merged with the main file • Multiple indexes for the same key field can be set up to increase efficiency
File Organization 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
File Organization The Direct or Hashed File • Directly access a block at a known address • Key field required for each record
File Sharing • In multiuser system, allow files to be shared among users • Two issues • Access rights • Management of simultaneous access