Transcription of Operating Systems - Lecture #5: File Management
1 Operating SystemsLecture #5:File ManagementWritten by David Goodwinbased on the Lecture series of Dr. Dayou Liand the bookUnderstanding Operating and McHoes(2006)Department of Computer Science and Technology,University of Systems , 201325thFebruary 201346 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsOutline1 Introduction2 Interaction with the file manager3 Files4 Physical storage allocation5 Directories6 File system7 Access8 Data compression9summary46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshire3 IntroductionInteraction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsIntroduction46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshire4 IntroductionInteraction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsIntroduction Responsibilities of the file manager1 Keep
2 Track of where each file is stored2 Use a policy that will determine where and how the files willbe stored, making sure to efficiently use the available storagespace and provide efficient access to the each file when a user has been cleared for access toit, and then record its the file when the file is to be returned to storage,and communicate its availability to others who may bewaiting for #5 FileManagementDavid GoodwinUniversity ofBedfordshire5 IntroductionInteraction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsDefinitionsfieldis a group of related bytes that can be identified bythe user with a name, type, and a group of related a group of related records that containsinformation to be used by specific applicationprograms to generate reports. This type of filecontains data and is sometimes called a flat file because it has no connections to other file; unlikedatabases it has no to be a type of file, but databases are morecomplex.
3 They are groups of related files that areinterconnected at various levels to give flexibility ofaccess to the data filescontain filescontain listings of filenames and their #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroduction6 Interaction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsInteraction with thefile manager46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroduction7 Interaction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsInteracting with the File Manager User communicates via commands, either embedded in user sprogram or submitted interactively by user. embedded commands are: OPEN / CLOSE - pertain to the availability of a file for theprogram invoking it. READ / WRITE - are I/O commands.
4 MODIFY - specialised WRITE command for existing datafiles, allows for appending records or for rewriting selectedrecords in their origional place in the file. interactive commands are: CREATE / DELETE - deal with the system s knowledge ofthe file (some Systems have the first instance of SAVE command, others OPEN NEW, OUTPUT. RENAME - allows users to change the name of an existingfile. COPY - lets users make duplicate copies of existing files. These commands (and many more) are designed to be simpleto make themdevice #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroduction8 Interaction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsInteraction with the File Manager Example - READ instruction:1 Move the read/write heads of the cylinder where the record isto be for the rotational delay until the sector containing thedesired record passes under the read/write the appropriate read/write head and read the the record to main a flag to indicate that the device is free to satisfyanother #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroduction9 Interaction with thefile managerFilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsVolume Configuration Each storage unit is considered avolume.)
5 Each volume in the system is given a name and otherdescriptive information contained on an easy-to-access place(innermaost part of CD, first sector of outermost track of adisk pack). Volume Descriptor: Creation date - date when volume was created. Pointer to diectory area - indicates first sector where directoryis stored. Pointer to file area - indicates first sector where file is stored. File system code - used to detect volumes with incorrectformats. Volume name - user-allocated name. TheMaster file directory (MFD)is stored immediatelyafter the volume descriptor lists the names and characteristics of every file contained inthat #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager10 FilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsFiles46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager11 FilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsFile attributes Information about files is kept in the directory structure,which is also maintained on the disk.
6 Name only information kept in human-readable form. Identifier non-human readable unique tag (usually anumber). Type needed for Systems that support different types. Location pointer to file location on device. Size current file size. Protection controls who can do reading, writing, executing. Time, date, and user identification data for protection,security, and usage #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager12 FilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsFile operations Create Write Read Reposition within file file seek Delete Truncate Open(Fi) search the directory structure on disk for entryFi, and move the content of entry to memory. Close (Fi) move the content of entryFiin memory todirectory structure on #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager13 FilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsFile types OS recognises and supports file types helps prevent user mistakes convenient by automatically doing various jobs after acommand must define every file type allowed and difficult to create newfile types Commonly implemented by using an extension name Creator attribute used to identify the file type and invoke thecreator application program Internal file structure can be indicated by file types46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager14 FilesPhysical storageallocationDirectoriesFile systemAccessData
7 CompressionsummaryOperating SystemsFile Types Two components are common to most filenames:1relative filename2extension (called a suffix in UNIX/Linux) A complete filename identifies a file sabsolute filename;being the long name that includes path information. there are restrictions on filename with each Operating system: MS-DOS - allows names from one to eight alphanumericcharacters, but without spaces most modern Operating Systems do not have restrictions onfilenames. An extension usually 2 or 3 characters long and is separatedby a period (.). The purpose is to identify the file type or itscontents. NOTE: some extensions are associated with more than oneapplication46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager15 FilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsFile types name and extension46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager16 FilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsAccess methods Sequential access Easiest File searched from its beginning until record is found Direct (relative/random)
8 Access Only on direct access storage devices Records identified by their relative address to the beginningof the file Indexed access Combines the best of sequential and direct access46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile manager17 FilesPhysical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsAccess methods - direct access example Records identified by logical address, them relative to thebeginning of the file. User identifies a field in the record format and designates it asthekey fieldbecause it uniquely identifies each record. the program used to store the data follows a set ofinstructions called ahashing algorithm, that transformseach key into a number, the record s logical address. This is given to the File Manager, which takes the necessarysteps to translate the logical address into a physical address(cylinder, surface, and record numbers)
9 , preserving the #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile managerFiles18 Physical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsPhysical storageallocation46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile managerFiles19 Physical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsPhysical storage allocation Contigious storage records stored one after another any record can be found and read by knowing its startingaddress and size ease of direct access, every part of the file is stored in thesame compact area file cant be expanded unless there is empty space immediatelyfollowing it - also causing fragmentation46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile managerFiles20 Physical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsPhysical storage allocation Noncontigious storage files use any space available on disk records stored in a contigious manner only if there s enoughempty space any remaining records, and all other additions to the file, arestored in other sections of the disk sometimes calledextentsof the file - linked together withpointers in one of two ways at storage level - each extent points to the next one insequence at directory level - each extent is listed with its physicaladdress, size.
10 And a pointer to the next extent. A null pointerindicates it s the last one. doesnt support direct access46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile managerFiles21 Physical storageallocationDirectoriesFile systemAccessData compressionsummaryOperating SystemsPhysical storage allocation Indexed storage brings together into an index block, the pointers linking everyextent of that file every file has its own index block deosn t improve storage supports direct access46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile managerFilesPhysical storageallocation22 DirectoriesFile systemAccessData compressionsummaryOperating SystemsDirectories46 Lecture #5 FileManagementDavid GoodwinUniversity ofBedfordshireIntroductionInteraction with thefile managerFilesPhysical storageallocation23 DirectoriesFile systemAccessData compressionsummaryOperating SystemsDirectory structure Directory is a collection of nodes containing informationabout all files.