中科大操作系统原理与实现课件10_FileSystem.pdf
《中科大操作系统原理与实现课件10_FileSystem.pdf》由会员分享,可在线阅读,更多相关《中科大操作系统原理与实现课件10_FileSystem.pdf(52页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、.操作系统原理与设计第10章 FS interface(文件系统概述)陈香兰中国科学技术大学计算机学院2009年12月.提纲File ConceptAccess MethodsDirectory StructureFile System MountingProtection小结和作业.File System.OutlineFile ConceptAccess MethodsDirectory StructureFile System MountingProtection小结和作业.File ConceptIOS provides a uniform logical view of infoma
2、tion storagedespite the various storage media.IA file is a logical storage unit.IA file is a named collection of related information that isrecorded on secondary storage.ITypes:IData:numeric;character;binaryIProgramIIn general,a file is a sequence of bits,bytes,lines,orrecords.Ithe meaning is define
3、d by the files creator and user.IContiguous logical address space.File Attributes.IName only information kept in human-readable formIA name is usually a string of characters,such as example.cIuppercase vs.lowercase;care or not careIIdentifier unique tag(number)identifies file within FSIit is the non
4、-human-readable name for the fileIType needed for systems that support different typesILocation pointer to file location on deviceISize current file size;may also include MAX sizeIProtection Access-control information:who can doreading,writing,executingITime,date,and user identification data for pro
5、tection,security,and usage monitoringIInformation about files are kept in the directory structure,which is maintained on the disk.File Operations IIFile is an abstract data type.OS provides the 6 basicsystem calls1.Create:allocate space+create an directory entry2.Write:write pointer3.Read:read point
6、er4.Reposition within file:also known as seek5.Delete:release space+erase the directory entry6.Truncate:file len=0;release space;all other attributesremain unchangedIothers:Ifor file:append,renameIfor file attribute:chown,chmod,.Ifor directory&directory entries:IOpen(Fi)search the directory structur
7、e on disk for entry Fi,and move the content of entry to memoryIClose(Fi)move the content of entry Fiin memory todirectory structure on disk.Open Files&Open-File Table IIOpen-file table:a small table containing information aboutall open filesISeveral processes may open the same file at the same timeI
8、2-levels:a per-process table&a system-wide table withprocess-independent informationISeveral pieces of data are needed to manage open files:IFile pointer:pointer to last read/write location,process-dependentIFile-open count:counter of number of times a file is open to allow removal of data from open
9、-file table when lastprocesses closes itIDisk location of the file:the information needed to locatethe file on disk,always is kept in memoryIAccess rights:per-process access mode information.Open Files&Open-File Table II.Open File LockingIProvided by some OSes and FSesIallow one process to lock a fi
10、le and prevent other processesfrom gaining access to itIfunctionality is similar to reader-writer locksIOS-or FS-dependentIOS may provide either Mandatory or advisory:IMandatoryIaccess is denied depending on locks held and requested;IOS ensures locking integrityIWindows OSesIAdvisoryIprocesses can f
11、ind status of locks and decide what to doIup to software developersIUNIX.File Types Name,Extension.File Structure IISometimes,file types can indicate the internal structure of fileIfile structuresINone-sequence of words,bytesISimple record structureILinesIFixed length;IVariable lengthIComplex Struct
12、uresIFormatted documentIRelocatable load fileICan simulate last two with first methodIsystem-supported file structuresIMost modern OSes support a minimal number of filestructures directlyIe.g.UNIX sees every file as a sequence of 8-bit bytes.File Structure IIIBenefits:Iapplications have more flexibi
13、lityIsimplifies the OSIinternel file structureIHow to locate an offset within a file?ILogical file(record)Physical blockIPacking is required to convert between logical records andphysical blocksIInternal fragmentation will occur.OutlineFile ConceptAccess MethodsDirectory StructureFile System Mountin
14、gProtection小结和作业.Access MethodsIFile store information.When it is used,this information mustbe accessed and read into computer memoryIOn a logical perspective of users,access a file of records1.Sequential Access2.Direct Access3.Indexed Access.Sequential AccessIinformation in the file is processed in
15、 order,one record afterthe other.IA tape model of file;IFile operations&the effect on file pointerread/write nextresetrewind/forward n.Direct Access IIInformation in the file is processed in no particular order.IFile is made up of fixed-length of logical recordsIA disk model of a fileICan move quick
16、ly to any record location by supplying arelative record number(n)IRead n&Write n,IFile pointer=L n,0 n N,where N is the last recordnumber,L is the fixed length of each record.IPosition n&read/write next,e.g.seek(20);/move to rec.20seek(-1);/move to rec.19read();ISimulation of Sequential Access on a
17、Direct-access File.Direct Access IIHow can we get n?If the record is with variable length,then?.Indexed Access IIMake an index file for the file,which contains pointers tovarious recordsIimproves search timeISearch the index file first,and then use the pointer to accessthe file directly and to find
18、the desired record.II/O is reducedIExample of Index and Relative Files.Indexed Access IIIWith large files,the index file itself may become to large to bekept in memoryIMulti-level index table.OutlineFile ConceptAccess MethodsDirectory StructureFile System MountingProtection小结和作业.A Typical File-syste
19、m Organization IIPartition(mini-disks,volumes)IOne diskIPart of a diskprovide separate logical spaces on one diskIN disksgroup several disks into a single logical spaceIFiles+directoriesIDirectoryIholds file information(e.g.name,location,size,type)for allfiles in that partition.A Typical File-system
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 中科大 操作系统 原理 实现 课件 10 _FileSystem
限制150内