Operating System 简明教程
Operating System - File System
File
文件是有名称的、相关信息的时间,记录在磁盘、磁带和光盘之类的二级存储设备上。一般来说,文件是比特、字节、行或记录的序列,其意义由文件的创建者和使用者定义。
A file is a named collection of related information that is recorded on secondary storage such as magnetic disks, magnetic tapes and optical disks. In general, a file is a sequence of bits, bytes, lines or records whose meaning is defined by the files creator and user.
File Structure
文件结构应遵照操作系统能够理解的所需格式。
A File Structure should be according to a required format that the operating system can understand.
-
A file has a certain defined structure according to its type.
-
A text file is a sequence of characters organized into lines.
-
A source file is a sequence of procedures and functions.
-
An object file is a sequence of bytes organized into blocks that are understandable by the machine.
-
When operating system defines different file structures, it also contains the code to support these file structure. Unix, MS-DOS support minimum number of file structure.
File Type
文件类型是指操作系统区分不同类型文件的这种能力,例如文本文件、源文件和二进制文件等。许多操作系统支持多种类型文件。像 MS-DOS 和 UNIX 这样的操作系统具有以下类型的文件 -
File type refers to the ability of the operating system to distinguish different types of file such as text files source files and binary files etc. Many operating systems support many types of files. Operating system like MS-DOS and UNIX have the following types of files −
Ordinary files
-
These are the files that contain user information.
-
These may have text, databases or executable program.
-
The user can apply various operations on such files like add, modify, delete or even remove the entire file.
Directory files
-
These files contain list of file names and other information related to these files.
Special files
-
These files are also known as device files.
-
These files represent physical device like disks, terminals, printers, networks, tape drive etc.
这些文件有两种类型——
These files are of two types −
-
Character special files − data is handled character by character as in case of terminals or printers.
-
Block special files − data is handled in blocks as in the case of disks and tapes.
File Access Mechanisms
文件访问机制指的是访问文件记录的方式。访问文件有几种方式——
File access mechanism refers to the manner in which the records of a file may be accessed. There are several ways to access files −
-
Sequential access
-
Direct/Random access
-
Indexed sequential access
Sequential access
顺序访问是以某种顺序访问记录,即文件中的信息按顺序处理,逐条记录。这种访问方法是最原始的。示例:编译器通常以这种方式访问文件。
A sequential access is that in which the records are accessed in some sequence, i.e., the information in the file is processed in order, one record after the other. This access method is the most primitive one. Example: Compilers usually access files in this fashion.
Direct/Random access
-
Random access file organization provides, accessing the records directly.
-
Each record has its own address on the file with by the help of which it can be directly accessed for reading or writing.
-
The records need not be in any sequence within the file and they need not be in adjacent locations on the storage medium.
Space Allocation
文件由操作系统分配磁盘空间。操作系统采用以下三种主要方式将磁盘空间分配给文件。
Files are allocated disk spaces by operating system. Operating systems deploy following three main ways to allocate disk space to files.
-
Contiguous Allocation
-
Linked Allocation
-
Indexed Allocation
Contiguous Allocation
-
Each file occupies a contiguous address space on disk.
-
Assigned disk address is in linear order.
-
Easy to implement.
-
External fragmentation is a major issue with this type of allocation technique.