《操作系统LEC9-文件管理》由会员分享,可在线阅读,更多相关《操作系统LEC9-文件管理(79页珍藏版)》请在金锄头文库上搜索。
1、Operating System,Lecture Nine File Management School of Software Nanjing University,本主题教学目标,掌握文件和文件系统的概念 了解文件系统的实现层次 掌握文件目录 掌握文件的组织与定位 掌握文件记录成组技术 掌握文件共享技术,File Management,File and File Management Implementation of File Management File Organization Directory File Sharing Blocking File Allocation File
2、 System Example,File Management,File management system is considered part of the operating system Input to applications is by means of a file Output is saved in a file for long-term storage,Terms Used with Files,Field:Basic element of data,Contains a single value,Characterized by its length and data
3、 type Record:Collection of related fields,Treated as a unit File:Stream of similar records (bytes / character),Treated as a single entity,Have unique file names,May restrict access Database:Collection of related data,Relationships exist among elements,Typical Operations,Typical Operations about Reco
4、rd File Retrieve_All, Retrieve_One, Retrieve_Next, Retrieve_Previous , Retrieve_Few Insert_One, Delete_One, Update_One Basic Operation about Stream File Open, Close, Read, Write, Seek,File Management System,The way a user of application may access files Programmer does not need to develop file manag
5、ement software,Objectives for a File Management System,Meet the data management needs and requirements of the user Guarantee that the data in the file are valid Optimize performance Provide I/O support for a variety of storage device types Minimize or eliminate the potential for lost or destroyed da
6、ta Provide a standardized set of I/O interface routines Provide I/O support for multiple users,Minimal Set of Requirements,Each user should be able to create, delete, read, and change files Each user have controlled access to other users files Each user may control what type of accesses are allowed
7、to the users files Each user should be able to restructure the users files in a form appropriate to the problem Each user should be able to move data between files Each user should be able to back up and recover the users files in case of damage Each user should be able to access the users files by
8、using symbolic names,File Management,File and File Management Implementation of File Management File Organization Directory File Sharing Blocking File Allocation File System Example,Device Drivers,Lowest level Communicates directly with peripheral devices Responsible for starting I/O operations on a
9、 device Processes the completion of an I/O request,Basic File System,Physical I/O Deals with exchanging blocks of data Concerned with the placement of blocks Concerned with buffering blocks in main memory,Basic I/O Supervisor,Responsible for file I/O initiation and termination Control structures are
10、 maintained Concerned with scheduling access to optimize performance Part of the operating system,Logical I/O,Enables users and applications to access records Provides general-purpose record I/O capability Maintains basic data about file,Access Method,Reflect different file structures Different ways
11、 to store and process data,File Management Functions,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 avai
12、lable blocks,Criteria for File Organization,Rapid access Needed when accessing a single record Not needed for batch mode Ease of update File on CD-ROM will not be updated, so this is not a concern Economy of storage Should be minimum redundancy in the data Redundancy can be used to speed access such
13、 as index Simple maintenance Reliability,File Management,File and File Management Implementation of File Management File Organization Directory File Sharing Blocking File Allocation File System Example,The Pile,Data are collected in the order they arrive Purpose is to accumulate a mass of data and s
14、ave it Records may have different fields No structure Record access is by exhaustive search,Pile,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 Uniquely ide
15、ntifies the record Records are stored in key sequence New records are placed in a log file or transaction file Batch update is performed to merge the log file with the master file,Sequential File,Indexed Sequential File,Index provides a lookup capability to quickly reach the vicinity of the desired
16、record Contains key field and a pointer to the main file Indexed is searched to find highest key value that is equal or less than the desired key value Search continues in the main file at the location indicated by the pointer,Comparison of sequential and indexed sequential,Example: a file contains 1 million records On average 500,00 accesses are required to find a record in a sequential file If an index contains 1000 entries, it will take on average 500 accesses to find the key, followed