操作系统英文教学课件:Chapter 10 File-System Interface

上传人:cl****1 文档编号:570173606 上传时间:2024-08-02 格式:PPT 页数:37 大小:1.58MB
返回 下载 相关 举报
操作系统英文教学课件:Chapter 10 File-System Interface_第1页
第1页 / 共37页
操作系统英文教学课件:Chapter 10 File-System Interface_第2页
第2页 / 共37页
操作系统英文教学课件:Chapter 10 File-System Interface_第3页
第3页 / 共37页
操作系统英文教学课件:Chapter 10 File-System Interface_第4页
第4页 / 共37页
操作系统英文教学课件:Chapter 10 File-System Interface_第5页
第5页 / 共37页
点击查看更多>>
资源描述

《操作系统英文教学课件:Chapter 10 File-System Interface》由会员分享,可在线阅读,更多相关《操作系统英文教学课件:Chapter 10 File-System Interface(37页珍藏版)》请在金锄头文库上搜索。

1、Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th Edition,Chapter 10: File-System Interface10.2Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionChapter 10: File-System InterfacenFile ConceptnAccess MethodsnDirectory Structure10.3Silberschatz, Galvin and Gagne 20

2、09Operating System Concepts 8th EditionObjectivesnTo explain the functionalities of file systemsnTo describe the interfaces to file systemsnTo discuss file-system design tradeoffs, including access methods, file sharing, file locking, and directory structures10.4Silberschatz, Galvin and Gagne 2009Op

3、erating System Concepts 8th EditionFile ConceptnOS provides a uniform logical view of infomation storage despite the various storage media (nonvolatile).nA file is a logical storage unit.lA file is a named collection of related information that is recorded on secondary storage.lTypes:4Data: numeric;

4、 character; binary4ProgramlIn general, a file is a sequence of bits, bytes, lines, or records.4The meaning is defined by the files creator and user.lA file has a certain defined structure, which depends on its type.4Example: text files, source files, object files, executable fileslContiguous logical

5、 address space10.5Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionFile ConceptnFile conceptl1. File attributesl2. File operationsl3. File typesl4. File structuresl5.Internal file structure10.6Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionFile Attribu

6、tesnA files attributes vary from one OS to another but typically consist of these:lName only information kept in human-readable formlIdentifier unique tag (number) identifies file within file systemlType needed for systems that support different typeslLocation pointer to file location on devicelSize

7、 current file sizelProtection controls who can do reading, writing, executinglTime, date, and user identification data for protection, security, and usage monitoring10.7Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionFile AttributesnInformation about files are kept in the dir

8、ectory structure, which is maintained on the disknTypically, a directory entry only consists of the files name and its unique identifier.nThe identifier in turn locates the other file attributes.10.8Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th Edition File Operations nFile is an

9、abstract data type. OS provides the 6 basic system callsl1. Create : allocate space + create an directory entryl2. Write : write pointerl3. Read : read pointerl4. Reposition within file : also known as seekl5. Delete : release space + erase the directory entryl6. Truncate : file len=0; release space

10、; all other attributes remain unchangednothers:lFor file : append, renamelFor file attribute: chown, chmod, : : :lFor directory & directory entries:4Open(Fi) search the directory structure on disk for entry Fi, and move the content of entry to memory4Close(Fi) move the content of entry Fi in memory

11、to directory structure on disk10.9Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionFile OperationsnOpen Files & Open-File TablelOpen-file table, OFT: a small table containing information about all open fileslSeveral processes may open the same file at the same time 2-levels: a

12、 per-process table & a system-wide table with process-independent information10.10Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionOpen FilesnSeveral pieces of data are needed to manage open files:lFile pointer: pointer to last read/write location, per process that has the fil

13、e openlFile-open count: counter of number of times a file is open to allow removal of data from open-file table when last processes closes itlDisk location of the file: cache of data access informationlAccess rights: per-process access mode information10.11Silberschatz, Galvin and Gagne 2009Operatin

14、g System Concepts 8th EditionOpen File LockingnProvided by some operating systems and file systemslallow one process to lock a file and prevent other processes from gaining access to itlfunctionality is similar to reader-writer lockslOS- or FS-dependentlMandatory or advisorynMandatory (强制):laccess i

15、s denied depending on locks held and requested;lOS ensures locking integritylWindows OsesnAdvisory(建议):lprocesses can find status of locks and decide what to dolup to software developerslUNIX10.12Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionFile Types Name, Extension10.13S

16、ilberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionFile StructurenSometimes, file types can indicate the internal structure of filenFile structures(文件结构)(逻辑上)lNone - sequence of words, byteslSimple record structure4Lines4Fixed length;4Variable lengthlComplex Structures4Formatted

17、document4Relocatable load file10.14Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th Editionfile structurenSystem-supported file structureslMost modern OSes support a minimal number of file structures directly4Example: UNIX sees every file as a sequence of 8-bit byteslBenefits:4Applic

18、ations have more flexibility4Simplifies the OS10.15Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionInternal file structurenInternel file structurelHow to locate an offset within a file?4Logical file (record) (vary in length)Physical block (fixed size)lSolution: Packing packin

19、g a number of logical records into physical blocks.4Pack & unpack: convert between logical records and physical blocks4Internal fragmentation will occur10.16Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionAccess MethodsnFiles store information. When it is used, this informati

20、on must be accessed and read into computer memorynOn a logical perspective of users, access a file of recordsl1. Sequential Access (顺序访问方式)l2. Direct Access (直接访问方式)l3. Indexed Access (索引访问方式)10.17Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionSequential AccessnSequential Ac

21、cess (顺序访问方式): the simplest access method. Information in the file is processed in order, one record after the other.lThis is a most common access mode. For example: editors, compilerslA tape model of filenFile operations & the effect on file pointerlread/write nextlresetlrewind/forward n10.18Silber

22、schatz, Galvin and Gagne 2009Operating System Concepts 8th EditionDirect AccessnDirect Access (直接访问方式) Information in the file is processed in no particular order.lFile is made up of a numbered sequence of fixed-length logical records4A disk model of a file, allow random access, immediate access For

23、 example: databaseslCan move quickly to any record location by supplying a relative record number (n) read n write n position to n read next write next rewrite n n = relative block number10.19Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionSimulation of Sequential Access on D

24、irect-access File10.20Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionIndexed AccessnTo improves search time and reduce I/Ol1. Make an index file for the file, which contains pointers to various recordsl2. Search the index file first,l3. and then use the pointer to access the

25、 file directly and to find the desired record.nWith large files, the index file itself may become too large to be kept in memory ) Multi-level index table10.21Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionExample of Index and Relative Files10.22Silberschatz, Galvin and Gagn

26、e 2009Operating System Concepts 8th EditionDirectory StructurenA collection of nodes containing information about all filesF 1F 2F 3F 4F nDirectoryFilesnBoth the directory structure and the files reside on disknBackups of these two structures are kept on tapes10.23Silberschatz, Galvin and Gagne 2009

27、Operating System Concepts 8th EditionInformation in a directory entrynInformation in a directory entrylFile attributeslNamelTypelAddresslCurrent lengthlMaximum lengthlDate last accessedlDate last updatedlOwner IDlProtection information10.24Silberschatz, Galvin and Gagne 2009Operating System Concepts

28、 8th EditionOperations Performed on DirectorynSearch for a filenCreate a filenDelete a filenList a directorynRename a filenTraverse the file system10.25Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionOrganize the Directory (Logically) to ObtainnEfficiency locating a file quic

29、klynNaming convenient to userslTwo users can have same name for different fileslThe same file can have several different namesnGrouping logical grouping of files by properties, (e.g., all Java programs, all games, )10.26Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionDirector

30、y Structuresn1. Single-level directory (单层目录)n2. Two-level directory (双层目录)n3. Tree-structured directory (树型结构目录)n4. Acyclic-graph directory (无环图目录)n5. General-graph directory (通用图目录)10.27Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionSingle-Level DirectorynA single director

31、y for all usersNaming problemGrouping problem10.28Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionTwo-Level DirectorynSeparate directory for each usernPath namenCan have the same file name for different usernEfficient searchingnNo grouping capability10.29Silberschatz, Galvin

32、and Gagne 2009Operating System Concepts 8th EditionTree-Structured Directories10.30Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionTree-Structured Directories (Cont)nEfficient searchingnGrouping CapabilitynCurrent directory (working directory)nAbsolute or relative path namenC

33、reating a new file is done in current directory10.31Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionTree-Structured Directories (Cont)nDelete a filerm nCreating a new subdirectory is done in current directorymkdir Example: if in current directory /mailmkdir countmailprogcopyp

34、rt exp countDeleting “mail” deleting the entire subtree rooted by “mail”10.32Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionAcyclic-Graph DirectoriesnHave shared subdirectories and files, with no cycles10.33Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th Edi

35、tionAcyclic-Graph DirectoriesnImplementationl1. Symbolic links (符号链接)4A special new directory entry (link)4The content of such file is the path name of the real file/directory4How to traverse a directory contains symbolic links?The operating system ignores these links when traversing directory trees

36、 to preserve the acyclic structure of the system.l2. Duplicates directory entries4Hard to maintain consistency10.34Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionAcyclic-Graph DirectoriesnTraversing problemlDifferent names, actual only one fileltraverse more than oncenDeleti

37、ng problemlIf direct deletes list dangling pointerlor preserve the file until all reference to it are deletedlSolutions:4File-reference list4Reference count: UNIXnHow to ensure there are no cycles?10.35Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionGeneral Graph DirectorynIf

38、 we allow cycles existed in directory10.36Silberschatz, Galvin and Gagne 2009Operating System Concepts 8th EditionGeneral Graph DirectorynThe traversing problem and deleting problem still exists, even more complicatedlylInfinite loop4limit the access number of a directory while for a searchlGarbage & garbage collectionnHow do we guarantee no cycles?lAllow only links to file not subdirectorieslEvery time a new link is added use a cycle detection algorithm to determine whether it is OKSilberschatz, Galvin and Gagne 2009Operating System Concepts 8th Edition,End of Chapter 10

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 研究生课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号