390 likes | 591 Views
Chapter 8 - File Management. Introduction - File Management. The File Manager controls every file in the system File Manager efficiency depends on: how the files are organized how they are stored how each file’s records are structures how access to the files are controlled.
E N D
Introduction - File Management • The File Manager controls every file in the system • File Manager efficiency depends on: • how the files are organized • how they are stored • how each file’s records are structures • how access to the files are controlled
The File Manager • Software is responsible for creating, deleting, modifying & controlling access to files • Manages the resources used by files • Provides support for libraries of programs & data to on-line users, spooling operations, & interactive computing • Functions are performed in collaboration with the Device Manager See Fig p.173
Responsibilities of the File Manager • Four tasks: • keep track of each file is stored • use a policy that will determine where & how files will be stored to maximum efficiency of storage space & file access • allocate each file for access & record use • deallocate the file when the file is to be returned to storage & communicate to other users its availability
File Management - Definitions • Field • a group of related bytes that can be identified by the user with a name, type, & size • Record • a group of related fields • File • a group of related records that contain information to be used by a specific application program to generate reports
File Management - Definitions • Database • groups of related files that are interconnected • Program files • contain instructions • Data files • contain data • Directories • listing of file names & their attributes
Interacting with theFile Manager • Users communicate with the File Manager via specific commands • Embedded commands • OPEN, CLOSE, READ, WRITE, MODIFY • pertain to the availability of a file for the program invoking it • Interactive commands • CREATE, DELETE, RENAME, COPY, SAVE • deal with the system’s knowledge of the file
Interacting with theFile Manager • Commands are the interface between the user & the hardware • Device Independent • to access a file, the user does not need to know its exact physical location on disk • each logical command is broken down into a sequence of low-level signals that trigger step-by-step actions performed by the device • with device independence, users can manipulate their files with commands
Typical Volume Configuration Each storage unit is considered a volume • tapes, floppy disk, hard disk, etc. • each volume can contain several files • each volume in the system is given name, just as files are named
Typical Volume Configuration The File Manager writes this name & other information at the beginning of a tape or the first sector of the outermost track of a disk called the volume descriptor • creation date • pointer to directory area • pointer to file area • file system code • volume name Once the volume descriptor is identified, the OS can interact with the storage unit See Fig 8.1 p.177
Typical Volume Configuration Master File Directory (MFD) is stored after the volume descriptor • lists the names & characteristics of files contained in that volume • file names in the MFD can be program, data, and/or system files • lists subdirectories • remainder of the volume is used for file storage See Fig 8.2 p.178
About Subdirectories File Managers create an MFD for each volume that contains entries for both files & subdirectories • a subdirectory is created by a user to store user files • its entry in the MFD is flagged to indicate to the File Manager that it is a subdirectory
About Subdirectories File directory tree structure allows the system to efficiently search subdirectories • Root is the MFD • Node is a directory file • Branch points to another directory or a file • Leaves are all programs and data files
About Subdirectories Each file entry in every directory contains information describing it; called file descriptor • file name, type, size, & location • date & time of creation • owner • protection information • record size
File Naming Conventions Every OS has specific rules for that affect the file name length Two components are commons: • relative file name • created by the user • extension • usually 2-3 characters in length, often created by application or can be created by user • BAT, EXE, BAS are recognized as standard & signal to the system specific programs • TXT, DOC, KEY user identification
File Naming Conventions • File Manager selects a directory for the user when an interactive session begins • File operations usually start from a “home” or “base” directory • Subdirectories selected from a home directory • current directory • working directory
File Organization • Record Format • All files are composed of records • fixed-length • most common & easiest to access directly • variable length • don’t leave empty storage but difficult to access directly
File Organization Physical File Organization • The way records are arranged and characteristics of storage medium used • On magnetic disks, files can be stored in one of three ways: • sequential • direct • indexed sequential
File Organization • The best file organization, consider these characteristics: • volatility of the data • activity of the file • size of the file • response time
File Organization • Sequential record organization • easiest to implement • records stored one after another • file is searched from its beginning until requested record is found • key field to sort records & is used to speed up search process
File Organization • Direct record organization • uses direct access files • can only be implemented using direct access storage devices • flexible to access records in any order without search starting at beginning of file • also known as “random organization” & files are known as “random access files” • key field is used to uniquely identify each record • hashing algorithm transforms each key into a record’s logical address
File Organization • Indexed sequential record organization • combines the best of sequential & direct access • created & maintained through Indexed Sequential Access Method (ISAM) software • uses file information to create an index file for efficient file retrieval • system searches the index file & then goes to the physical location indicated in that entry
Physical Storage Location • File Manager must work with files not just as whole units but also as logical units or records • Records within a file must have the same format but can vary in length • File storage = record storage • File & Device Managers must cooperate to ensure successful storage & retrieval of records See Fig 8.3 p.184
Physical Storage Allocation • Contiguous Storage • records stored one after another Advantages • simple to implement & easy to manage • ease of direct access Disadvantages • files cannot be expanded unless there is empty space immediately following it • fragmentation, slivers of unused space See Fig 8.4 p.185
Physical Storage Allocation • Noncontiguous Storage • allows files to use any storage space available on the disk • file’s records are stored contiguously if there is enough empty space, if not stored in other sections of the disk • called extents of a file & are linked together with pointers • eliminates external storage fragmentation & the need for compaction, does not support direct access See Fig 8.5-6 p.186&187
Physical Storage Allocation • Indexed Storage • allows direct access by bringing together into an index block the pointers linking every extent of that file • every file has its own index block consisting of the addresses of each disk sector that makes up the file • larger files with more entries, several indexes can be generated See Fig 8.7 p.188
Data Compression • Technique used to save space in files • 3 methods • records with repeated characters • repeated terms • front-end compression • Trade-off: storage space is gained but processing time is lost • For all data compression schemes, the system must be able to distinguish between compressed & uncompressed data See Tab 8.1 p.189
Access Methods • Dictated by a file’s organization • most flexibility is allowed with indexed sequential & least with sequential • With sequential access: • File Manager uses the address of the last byte read to access the next record • Current Byte Address (CBA) must be updated every time a record is accessed, such as when a READ command is executed See Fig 8.8 p.190
Access Methods • Fixed length records • have the same number of bytes to a record, so (RL) record length is a constant • the CBA is updated by incrementing it by the record length • Variable length records • RL is not constant • the CBA can be computed directly from the RL and the desired record number (RN) minus 1
Levels in a File Management System • Efficient file management cannot be separated from device management • Many hierarchies exist to perform I/O functions • Each level of the file management system is implemented by using structured & modular programming design • Each module can be further subdivided into more specific tasks
Levels in a File Management System Typical modules of a file management system: • Basic File System • Access Control Module • Logical File System • Physical File System • Device Interface Module • Devices See Fig 8.9 p.192
Levels in a File Management System Information used by the basic file system, OS active file table information: • record size • address of its first physical record • it’s protection • access control information • access control verification module • device interface module • allocation module
Access Control Verification Module Any file can be shared • data files • user-owned program files • system files • advantages • saving space • synchronization of data updates • efficiency of system resources
Access Control Verification Module File Sharing • disadvantages • integrity of files must be safeguarded by • controlling who is allowed access • controlling what type of access is permitted Each file management system has its own method to control file access
Access Control Verification Module Four common control file access methods • Access Control Matrix • Access Control Lists • Capability Lists • Lockwords See Tab 8.2-8.4 p.194-195
Summary • File Manager controls every file system & processes user commands to interact with any file on the system • File Manager manages the access control procedures to maintain the integrity & security of files under its control
Summary • File Manager must be able to accommodate a variety of • file organizations • physical storage allocation schemes • record types • access methods
Summary • Sequential, direct, & indexed file organization methods • Contiguous, noncontiguous, & indexed file storage allocation methods • Fixed - versus variable length records • Four methods of access control
Summary • OS File Manager requires complex file management software • It is important for users to realize the strengths & weaknesses of its segments • access methods are allowed on which devices & with which record structures • advantages & disadvantages of each in overall efficiency