This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

1. Document Management

1.1 Index File Structure

As shown in the following figure, the system has 13 index nodes. 0 to 9 are direct indexes, that is, each index node stores content. Assume that the size of each physical disk is 4KB, and a total of 10KB data can be stored by 4KB x 10.

Index node 10 is a level 1 indirect index node with a size of 4KB. It stores addresses linked to direct physical disks rather than direct data. Assuming that each address occupies 4B, there are 1024 addresses corresponding to 1024 physical disks, which can store 4098KB of data.

The direct disk stores the level-1 address, and the level-1 address stores the fast address of the physical disk, which is then linked to the physical disk block for storing data. The capacity of the level-2 index node is increased by one order of magnitude to 10,2410,244 KB.

1.2 File and Tree Directory Structure

File security is divided into four levels, from high to low, respectively: system security, user security, directory security, file security.

  • Relative path: the path starting from the current path.
  • Absolute path: the path from the root directory.

Full file name = Absolute path + File name. Note that absolute and relative paths do not have a final file name, just a simple sequence of paths.

  • The tree structure is mainly used to distinguish relative paths from absolute paths, as shown in the following figure:

1.3 Managing Free Storage Space

  • Free area table method: consolidate all free space into one table, that is, free file directory.
  • Free linked list method: All free Spaces are linked into a linked list and allocated as needed.
  • Group chaining: grouping and linking into linked lists within each group is a combination of the above two methods.
  • Bitmap method:important, each physical space is marked with a bit. If it is 1, it is used, and if it is 0, it is free, forming a bitmap.

2. Equipment Management

Classification of equipment:

  • Classified by data organization: block devices, character devices.
  • Resource allocation: Exclusive device, shared device, and virtual device.
  • Data transmission rates are classified into low-speed devices, medium-speed devices, and high-speed devices.

2.1 I/O software

The following figure shows all layers of the I/O device management software and the functions of each layer:

2.2 Input/output technology

Program control (query) mode: CPU actively queries whether peripherals complete data transmission, very low efficiency.

Program interrupt mode: The peripheral sends interrupt to the CPu after data transmission and waits for the CPu to process data, which is relatively efficient. Suitable for keyboard and other real-time scenarios.

Interrupt response time refers to the time from issuing interrupt request to entering interrupt handler; Interrupt processing time refers to the period from the beginning of interrupt processing to the end of interrupt processing. The interrupt vector provides the entry address of the interrupt service routine. Multi-level interrupt nesting, using a stack to protect breakpoints and the scene.

DMA mode (direct main memory access): the CPU only needs to complete the necessary initialization and other operations, the whole process of data transfer is completed by DMA controller, between main memory and peripheral establish a direct data path, high efficiency. Suitable for high-speed devices such as hard disks.

At the end of a bus cycle, the CPu begins reading data in response to DMA requests; The CPU responds to interrupt mode requests at the end of an instruction execution; Distinguish between end of instruction execution and end of bus cycle.

Channel: Also a processor that has an independent processing system inside so that data is transferred independently of the CPU. It is divided into the transmission mode of byte multi-channel (each time a byte of a channel is transmitted, the multi-channel cycle) and the transmission mode of select channel (select a channel, transmit all the bytes of this channel first, and then start the next channel transmission).

2.3 Virtual Devices and SPOOLING Technology

A physical device, such as a printer, can only be used by one process at a time, and other processes can only wait and do not know when the printer is idle. In this case, the work efficiency of peripherals is greatly wasted.

Introduction of SPOOLING technology, two data buffer is built on the peripheral, referred to as the input shaft and output shaft respectively, in this way, no matter how many process, all can share the printer, just need to print command issued, data will queue stored in buffer, the printer automatically in order to print, realize the sharing of physical device, Making each process feel like it is using a printer is the virtualization of physical devices. As shown below:

Three micro kernel operating system

Microkernel, as the name implies, is to make the kernel as small as possible, put only the most core necessary things into the kernel, other independent things into the user process, so that the system is divided into user state and kernel state, as shown in the following figure:

Advantages and disadvantages of single-core and microkernel are also introduced above. Single-core is convenient for process switching, but the kernel is large and weak in stability. Microkernel has high stability and is easy to cut, but switching between processes consumes resources and is inefficient.

Embedded operating system

  • Embedded operating system features: miniaturization, high code quality, specialization, strong real-time, tailoring and configuration.
  • Kernel services for real-time embedded operating systems: exceptions and interrupts, timers, I/ O management.
  • Common embedded RTOS(real-time operating system): vxWorks, RT-Linux, QNX, pSOs.