The file structure of the operating system

file structure

The index file structure used in the computer system is shown in the following figure:

There are 13 inodes in the system, 0-9 are direct indexes, that is, each inode stores content. Assuming that the size of each physical disk is 4KB, a total of 4KB*10=40KB of data can be stored; the 10th inode is a Level indirect index node, with a size of 4KB, does not store direct data, but an address linked to a direct physical disk block. Assuming that each address occupies 4B, 4kb/4B=1K, there are 1024 addresses in total, corresponding to 1024 physical disks , can store 1024* 4KB=4098KB data.

Similar to the secondary inode, the first-level address is stored directly on the disk, the first-level address is then stored with the physical disk fast address, and then linked to the physical disk block where the data is stored.

tree file directory

Relative path: is the path from the current path.

Absolute path: is the path starting from the root directory.

Full filename = absolute path + filename. Note that absolute and relative paths do not add the final filename, but are simply a sequence of paths.

The tree structure mainly distinguishes relative paths and absolute paths, as shown in the following figure:

Free storage space management

Free area table method: Integrate all free space into a table, that is, the free file directory.

Free linked list method: Link all free space into a linked list and allocate it as needed.

Group linking method: It is a combination of the above two methods.

Bitmap method : use one bit to identify each physical space, if it is 1, it is used, and if it is free, a bitmap is formed.

Device management

Classification of equipment:

Classification by data organization: block device, character device.

Resource allocation perspective classification: exclusive devices, shared devices and virtual devices.

Data transfer rate classification: low-speed devices, medium-speed devices, and high-speed devices.

Input and output technology

Program control (query) mode: The CPU actively queries whether the peripherals have completed data transmission, which is extremely inefficient.

Program interrupt mode: After the peripheral completes data transmission, it sends an interrupt to the CPU and waits for the CPU to process the data, which is relatively efficient. It is suitable for scenes with high real-time performance such as keyboards.

The interrupt response time refers to the time from when the interrupt request is issued to the start of entering the interrupt handler; the interrupt processing time refers to the time from the start of the interrupt process to the end of the interrupt process. The interrupt vector provides the entry address of the interrupt service routine. Multi-level interrupt nesting, using stack to protect breakpoints and sites.

DMA mode (direct main memory access): The CPU only needs to complete the necessary initialization and other operations, the entire process of data transmission is completed by the DMA controller, and a direct data path is established between the main memory and peripherals, which is very efficient . Suitable for high-speed devices such as hard disks.

After a bus cycle is over, the CPU will respond to the DMA request to start reading data; the CPU responds to the program interrupt request at the end of an instruction execution; distinguish between the end of instruction execution and the end of the bus cycle.

Virtual Devices and SPOOLING Technology

An actual physical device, such as a printer, can only be used by one process at the same time, and other processes can only wait, and do not know when the printer is idle. At this time, the work efficiency of the peripheral device is greatly wasted.

The introduction of SPOOLING technology is to establish two data buffers on the peripheral device, which are called input wells and output wells. In this way, no matter how many processes are, this printer can be shared, and the data will be queued for storage as long as the print command is issued. In the buffer, the printer will automatically print in order, which realizes the sharing of physical peripherals, so that each process feels that it is using a printer. This is the virtualization of physical devices. As shown below:

disk structure

The disk has two surfaces, front and back, each surface has multiple concentric circles, each concentric circle is a track, and each concentric circle is divided into multiple sectors, and data is stored in each sector.

When reading data, the magnetic head must first find the corresponding track, and then wait for the disk to rotate periodically and rotate to the specified sector before the corresponding data can be read. Therefore, the seek time and waiting time will be generated, which is the movement of the magnetic head. The time it takes to reach the track and the time it takes for the sector waiting to be read or written to go under the head. The seek time is the longest, and the scheduling algorithm of the seek time is as follows:

First-come, first-served FCFS: Scheduling is performed according to the order in which the process requests access to the disk.

Shortest seek time priority SSTF: The process that requests access to the track closest to the current track is scheduled first, so that each seek time is the shortest. There will be a "starvation" phenomenon, that is, distant processes may never be accessible.

Scanning algorithm SCAN: also known as "elevator algorithm", the head moves in both directions on the disk, it will select the track that is closest to the track where the head is currently located, and is consistent with the direction of the head movement, the head is always from the inside to the outside or from the It keeps moving from outside to inside before turning around, similar to an elevator.

One-way scan scheduling algorithm CSCAN: Unlike SCAN, it only moves in one direction, that is, it can only move from inside to outside or from outside to inside.

embedded operating system

Embedded operating system features: miniaturization, high code quality, specialization, strong real-time performance, tailorable and configurable.

Kernel services for real-time embedded operating systems: exceptions and interrupts, timers, /management.

Common embedded RTOS (real-time operating system): VxWorks, RT-Linux, QNX, pSOS.

The initialization process of the embedded system is in the order from bottom to top and from hardware to software:

Chip level initialization -> board level initialization -> system initialization.

The chip level is the initialization of the microprocessor, the board level is the initialization of other hardware devices, and the system level initialization is the initialization of the software and operating system.

Guess you like

Origin blog.csdn.net/flysh05/article/details/124181783