Skip to content

File Usage

File storage structure and usage

  • The storage structure of a file is not only related to the physical characteristics of the storage device, but also to how users use the file.
  • Files are stored in secondary storage space. When a file is accessed, it must be read from secondary storage into main memory.

File table

  • System open file table: The entire system provides a system open file table to track all files in use.
  • User Open File Table: Each user has a user open file table, which is used to track the files that the user is using.
  • Shared files: When multiple processes share the same file, the open file tables of multiple users must correspond to the same entry address of the system's open file table.

Basic operations on files

Each basic operation is also called a file operation primitive, which mainly includes the following six operations:

  1. Create file operation: Create a new file.
  2. Open file operation: Open an existing file so that it can be read and written.
  3. Read file operation: Read data from the file.
  4. Write file operation: Write data to the file.
  5. Close file operation: Close the opened file.
  6. Delete file operation: Delete a file.

File access process

The file access process varies depending on the type of operation. Here are several common file access processes:

  1. Read file:

  2. Write file:

  3. Delete files: