1 / 82

Chapter 5 File Management

Chapter 5 File Management. Contents. File and file system overview Logical organization of file File directories and file sharing Physical organization of file (secondary storage management). 5.1 File and File System Overview. Basic Concept (pp501) Field Record File Database

Download Presentation

Chapter 5 File Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5 File Management

  2. Contents File and file system overview Logical organization of file File directories and file sharing Physical organization of file (secondary storage management)

  3. 5.1 File and File System Overview • Basic Concept (pp501) • Field • Record • File • Database • File Management System • Database Management System

  4. Field • A field is the basic element of data • Field may be fixed length or variable length • Attribution of field include name, length, type, default…

  5. Record • A record is a collection of related fields that can be treated as a unit by some application programs. • A record may be fixed length or variable length. • Key field: can be seen as the identify of the record.

  6. File • A file is a collection of similar records or a streaming of byte. • Access control restrictions may apply at file or record or field.

  7. File Attribution • Name • Length • Access control • Create time , modify time • Physical address • Where they are?

  8. Database • Database is a collection of related data. • The database itself consists of one or more types of files.

  9. Database Operations • Retrieve_all • Retrieve_one • Retrieve_next • Retrieve_previous • Insert_one • Delete_one • Update_one • Retrieve_few

  10. File Management Systems (p503) • A set of system software to manage files of the system and provides services to users and applications in the use of files.

  11. File Management Systems • A separate file management systems may provide for some special storage systems. • Mostly, the entire file management system is considered part of the operating system.

  12. Database Management Systems • It can be independent of operation system. • It can have an independent file system or use file systems of operation system. • Database file is referred as structure file.

  13. Objectives for a File System pp503 • To meet(满足) the management requirements of the user. • To guarantee the data in file are valid. • To optimize performance of the file access. • To support for a variety of storage device type.

  14. Objectives for a File System • To eliminate the potential for lost data. • To provide a standardized set of I/O interface. • To provide I/O support for multiple users.

  15. Minimum Requirement • Create、delete and update file. • Each user may have controlled access to other users’ files. • Each user may control what type of accesses are allowed to the users’ files. • Each user should be able to restructure the user’s files in a form appropriate to the problem.

  16. Minimum Requirement • Each user should be able to move data between files. • Each user should be able to backup and recover the user’s files in case of damage. • To access the user’s files by a symbolic(符号) name.

  17. Example : FAT • BOOT section • FDT(file directory table) • FAT1/FAT2(file allocation table) • DATA section

  18. 磁盘盘区划分表

  19. 操作流程 磁盘参数表 磁盘目录表 FDT 文件位置分配 表FAT 文件名 磁盘基数表 扇区物理 操作 磁盘扇区 定位

  20. File Operations • Read/write • Lseek • Lstate • Unlink • Open • Close • ……

  21. File Management Function pp505 • Identify and locate the selected file: Lookup(查找) the directories of the file systems to get the location of the file.(按名存取) • In sharing file systems, accessing control should be verified.

  22. File Management Function • To map the logical unit (record/byte) to physical unit (block) . • To allocate free block for files. • To manage the free block of secondary storage.

  23. Elements of File Management

  24. File System Architecture(p504)

  25. Device Drivers • Lowest level. • Communicates directly with peripheral devices(外设). • Responsible for starting I/O operations on a device. • Processes the completion of an I/O request.

  26. Basic File System • Physical I/O. • Deals with exchanging blocks of data. • Concerned with the placement of blocks between disk-cash and memory.

  27. Basic I/O Supervisor • Responsible for file I/O initiation and termination. • Control structures (e.g.SDT) are maintained. • Concerned with scheduling access to optimize performance. • Part of the operating system.

  28. Logical I/O • Enables users and applications to access records. • Provides general-purpose record I/O capability.

  29. Access Method • Reflect different file structures. • Different ways to store and process data.

  30. Criteria for File Organization(p507) • 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.

  31. Criteria for File Organization • Economy of storage • Should be minimum redundancy in the data. • Redundancy can be used to speed access such as an index. • Simple maintenance. • Reliability.

  32. 5.2 Logical Organization of File • The pile. • The sequential file. • The indexed sequential file. • The indexed file. • The direct, or hashed file.

  33. The Pile • Data are collected in the order they arrive. • Purpose is to accumulate a mass of data and save it. • Records may have different fields. • No structure. • Record access is by exhaustive search.

  34. The Pile

  35. The Sequential File • Fixed format used for records so 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 field. • Uniquely identifies the record. • Records are stored in key sequence.

  36. The Sequential File • Is the only type that is easily stored on tape as well as disk. • Poor performance. • New records are placed in a log file or transaction file. • Batch update is performed to merge the log file with the master file.

  37. The Sequential File

  38. Indexed Sequential File • Index provides a lookup(查找) capability to quickly reach the vicinity(邻近) of the desired 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.

  39. Comparison of Sequential and Indexed Sequential • Example: a file contains 1 million records • On average 500,000 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 by 500 accesses in the main file. Now on average it is 1000 accesses.

  40. Indexed Sequential File (Insert) • New records are added to an overflow file. • Record in main file that precedes it is updated to contain a pointer to the new record. • The overflow is merged with the main file during a batch update. • Efficiency is not high , and only one index.

  41. Indexed Sequential File

  42. Indexed File • Uses multiple indexes for different key fields. • May contain an exhaustive( 耗尽) index that contains one entry for every record in the main file. • May contain a partial index. • The index is a sequential file with fixed records.

  43. Indexed File

  44. Hashed File • Directly access a block at a known address • Key field required for each record

  45. 5.3 File Directories (table 12.2) • Contains information about files • Attributes • Location • Ownership • Directory itself is a file owned by the operating system • Provides mapping between file names and the files themselves

  46. Simple Structure for a Directory • It may only include the key elements: name,address,size and organization. • So most of the files’ directory can cash to memory to improve the search speed.

  47. Basic Operations • Search(lookup) • Create file • Delete file • List directory

  48. Type of Directory • Single-level • Two-level • Multi-level

  49. Single Level • List of entries, one for each file. • Sequential file with the name of the file serving as the key. • Provides no help in organizing the files. • Forces user to be careful not to use the same name for two different files.(不能重名)

  50. Two Level • One directory for each user and a master directory(主目录). • Master directory contains entry for each user. • Provides address and access control information • Each user directory is a simple list of files for that user. • Still provides no help in structuring collections of files.

More Related