Home > Common Problem > How does the operating system manage programs and data?

How does the operating system manage programs and data?

醉折花枝作酒筹
Release: 2023-02-16 14:40:35
Original
8009 people have browsed it

The operating system manages programs and data through the file system. The management function of the file system is achieved by organizing the programs and data it manages into a series of files. A file refers to a collection of several related elements with file names.

How does the operating system manage programs and data?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

Modern OS almost all organizes and manages a large number of programs and data stored in the computer through the file system. The management function of the file system is achieved by organizing the programs and data it manages into a series of files. A file refers to a collection of several related elements with file names. Elements are usually records, and a record is a collection of meaningful data items. Data components can be divided into data items, records, and files.

①Data item, data item is the lowest level data organization form. It is divided into basic data items (a character set used to describe a certain attribute of an object, which is the smallest logical data unit that can be clearly understood in data organization, that is, atomic data, also known as data elements or fields) and combined data items (consisting of several Basic data items)

 ② A record is a collection of related data items, used to describe the attributes of an object in a certain aspect. In order to uniquely identify a record, it needs to be included in each data item of a record. Determine one or several data items and call their set a key. A key is a data item that can uniquely identify a record.

 ③ File, a file is a collection of related elements with a file name, divided into structured files (also called record files: files are composed of a group of similar records. For example, the files of all candidates applying for a certain school Application information records) and unstructured files (also known as streaming files: regarded as a stream of characters. Such as a binary file or character file). Structured files are composed of several related records, while unstructured files are regarded as a character stream. A file is the largest unit of data in a file system. The file should have its own attributes, including file type (such as source file, target file, executable file, etc.), file length (the current length of the file, and possibly the maximum allowed length), and the physical location of the file (indicating where the file is The pointer on the device and where it is on the device), the creation time of the file (the last modification time of the file). A file can correspond to several records, and a record can correspond to several data items.

The objects managed by the file system include: files (as direct objects of file management), directories (in order to facilitate users’ access and retrieval of files, directories are configured in the file system. Each directory entry must Contains the file name and the physical address of the file. The organization and management of the directory is the key to facilitate and improve the speed of file access), disk (files and directories must occupy storage space, effective management of this part of space, not only can Improve the utilization of external memory and improve the access speed to files).

Attributes of the file

①Name: The file has a unique name and is saved in an easily readable form.

②Identifier: A unique label that identifies a file in the file system, usually a number. It is an internal name that is unreadable by humans.

③Type: Used by file systems that support different types.

④Location: Pointer to the device and files on the device.

⑤Size: The current size of the file (expressed in bytes, words, or blocks), which may also include the maximum value allowed by the file.

⑥Protection: Access control information to protect files.

⑦Time, date and user identification: Information related to file creation, last modification and last access, used to protect, secure and track the use of files.

Basic operations of files

 ① Create a file. When creating a new file, the system must first allocate the necessary external memory space for the new file, and in the directory of the file system, To create a directory entry, the directory entry should record the file name of the new file and its external storage address and other attributes.

 ② Delete a file. When a file is no longer needed, it can be deleted from the file system. When deleting, the system should first find the directory entry of the file to be deleted from the directory and make it empty. item and then reclaim the storage space occupied by the file.

 ③ Read a file. When reading a file, the file name and the memory target address to be read must be given in the corresponding system call. At this time, the system needs to search the directory, find the specified directory entry, and obtain the location of the read file in the external memory. Within the directory entry, there is also a pointer for reading/writing files.

 ④ Write a file. When writing a file, the file name and its source address in memory must be given in the corresponding system call. At this time, the system needs to search the directory, find the specified directory entry, and then use the write pointer in the directory to perform write operations.

 ⑤ Truncate the file. If the contents of a file are outdated and need to be completely updated, one method is to delete the file and create a new file again. However, if the file name and attributes have not changed, you can truncate the file. method, which sets the original file length to 0 and discards the content of the original file.

 ⑥ Set the read/write position of the file, which is used to set the position of the file read/write pointer, so that every time you read/write the file, you do not need to start from the beginning but from the set position. Sequential access can be changed to random access.

Opening and closing files

Source: Most of the file operations provided by the current OS generally follow the following two steps: First, search the file directory to find the specified file. attributes and their location on the external memory; then, perform corresponding operations on the file, such as reading/writing files, etc. When the user requires multiple read/write or other operations on a file, each time it must start from the retrieval directory In order to avoid retrieving directories multiple times, the open file system call is introduced in most OSs. When the user requests an operation on a file system for the first time, the open system call is first used to open the file.

Open means that the system copies the attributes of the named file (including the physical location of the file on the external storage) from the external storage to an entry in the memory open file table, and adds the entry number (index number) ) is returned to the user. In the future, when the user requests to operate the file again, he or she can use the index number returned by the system to make an operation request to the system, and the system can directly use the index number to search in the open file table, thus This avoids retrieval of the file. If the user no longer needs to perform operations on the file, the close system call can be used to close the file. The OS will delete the file from the entry in the open file table.

Logical structure type of file

无结构文件(流式文件)
Copy after login

Unstructured file is the simplest form of file organization. Unstructured files organize data into records in order and accumulate and save them. It is a collection of ordered related information items, measured in bytes. Since unstructured files have no structure, records can only be accessed through exhaustive searches, so this file format is not suitable for most applications. However, the unstructured file management of character streams is simple and users can operate it conveniently. Therefore, those files that do not operate many basic information units are more suitable for the unstructured method of using character streams, such as source programs, executable files, library functions, etc.

有结构文件(记录式文件)
Copy after login

For more computer-related knowledge, please visit the FAQ column!

The above is the detailed content of How does the operating system manage programs and data?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template