A preliminary understanding of the operating system (Operator System)

1. Von Neumann Architecture

insert image description here
Among the many computer-related books, the von Neumann architecture must be mentioned, which is still used in today's computers.
Five members of computer hardware:

  • input device
  • output device
  • memory
  • controller
  • If a computer
    wants to work, these five parts are indispensable. The data processed by the computer is input from the input device and flows to the memory. The CPU reads the data from the memory and puts the processed result back into the memory. Output the processed result through the output device.

The important role of memory

The memory is also the memory, which plays a very important role. It serves as a bridge between the CPU and the peripherals. (Peripherals refer to input devices, output devices, such as disks, graphics cards, network cards, keyboards, monitors, etc.)

Since the calculation speed of the CPU is very fast, which is many times that of the general peripherals, if the peripherals communicate directly with the CPU, it is conceivable that the peripherals will greatly reduce the speed of the CPU, just like the barrel effect. How much water a barrel can hold is determined by the shortest plank.
insert image description here
The memory acts as a buffer between the CPU and the peripherals. Compared with the peripherals, the speed of the memory is very fast. Compared with the CPU, it is still relatively slow, but at least it is much faster than the peripherals. When processing data, the memory will preload part of the data in the peripherals into the memory for processing by the CPU.
What I have to say here isPrinciple of locality:According to the principle of statistics, when a piece of data is being accessed, there is a high possibility that the surrounding data will be accessed next time. So when the CPU needs to get a row of data, the memory can load the data around the row of data together, andCPU processing data and memory loading data can be carried out at the same time, so that the next time the CPU can directly get the data in the memory.

A few points to emphasize about the von Neumann system:

  • The storage here refers to the memory
  • Regardless of the cache, the CPU here can and can only read and write memory, and cannot access peripherals
  • To input or output data, peripherals can only write to or read from memory
  • In short, all devices can only deal with memory

Now you should understand why the executable program we write must be loaded into memory before running, because the running of the program needs to be processed by the CPU, and the CPU only deals with memory.

Second, the concept of the operating system

Any computer system includes a basic collection of programs called an operating system (OS).

A general understanding of the operating system includes:

  • Kernel (process management, memory management, file management, driver management)
  • Other programs (such as function libraries, shell programs, etc.)

Third, the purpose of designing the operating system

  • Interact with hardware and manage all hardware and software resources
  • Provide users with a good execution environment

Third, the positioning of the operating system in the computer system

An operating system is a piece of software that manages hardware and software resources

First of all, the bottom layer of the computer is some hardware, which forms the von Neumann architecture between them.
insert image description here
However, they alone cannot get the job done, a software is needed to manage them.
For example: the memory we introduced above will load the data in the input device, but when is it loaded? How much is it loaded? He can't do his job without something managing it, and the software that manages them isoperating system(Operator System).
However, the OS does not directly communicate with the underlying hardware. For example, if the operating system completes the keyboard reading operation, as long as your keyboard reading method is changed, the kernel source code of the operating system needs to be recompiled. , which is too expensive to maintain for the operating system.
Therefore, a layer of hardware driver is added between the hardware and the operating system. The main job of the driver layer is to control the underlying hardware alone. For example: the keyboard has a keyboard driver, the graphics card has a graphics card driver, the network card has a network card driver, and the hard disk has a hard disk driver. Simply speaking, the driver is to access a certain hardware, access the reading, writing and hardware status of the hardware, etc. The driver layer directly deals with the hardware. The driver is generally provided by the hardware manufacturer, or developed by the module related to the operating system.
At this point, the operating system only needs to care about when to read the data, not how to read the data, which completes the decoupling between the operating system and the hardware.

insert image description here
The main work of the operating system:

  • process management
  • memory management
  • file management
  • driver management

insert image description here
The operating system manages the bottom in this way, but what does it do with the top?
Will the operating system directly allow users to operate it to manage hardware? The answer is definitely not.

An operating system is a discreet piece of software that does not expose itself to the user, but throughsystem call interfaceThis is very similar to a bank in real life. There will be a large glass wall in the bank, and there will be many service windows through which the bank provides services to the outside world.
insert image description here
The bank does this because it needs to provide services to the outside world, but it also needs to protect its own safety. What if the person who goes to the bank to handle business is a bad person.
The same is true for the operating system. In order to prevent damage from others, the way it provides services to the outside world is to expose somesystem interface.
insert image description here
Only a small number of professionals can use the system interface, so there is another layer above the system interface, such as: shell command line interpreter, GUI graphical interface, function library, etc., to help people call the program of the system interface .

insert image description here
Based on such a foundation, users can use computers with ease, and users are the top layer.

insert image description here
It can be seen that the computer system is actually a layered structure.

Fourth, how the operating system is managed

When it comes to how the operating system manages hardware and software resources, let’s start with an example. How do school leaders manage students?

There are at least 10,000 students in a university. If the principal communicates directly with each student for management, it will have to be managed until the year of the monkey. This is unrealistic.
The principal has the data of each of us, and he manages us through our data. For example, one day the principal found the instructor of the School of Computer Science and told him to commend the top students of the school. Could it be that the principal Will you go to see everyone's results one by one and find out the top few? Obviously not, he has the student's data in his hand. If the principal is a principal who understands computers, he creates such a structure based on the common characteristics of the students, which includes name, student number, credits, grade points, etc., so In the eyes of the principal, each student is a structure. With so many structures, how to check the top students? The answer is to organize these structures, for example, store them in a linked list data structure, and then find the students to be commended by traversing the linked list.
The principal's management of students actually manages the data of the students. Students are like the hardware in the computer, the principal is the operating system, and the hardware driver is the counselor. The principal does not care how its orders are implemented, he only cares about his decision-making. As for how to implement it, that is the counselor's business .

The operating system is actually the role of the principal and a manager. He will not directly communicate with the hardware, but the data of the hardware in his hands. It manages the hardware through the data of the hardware. As for the specific implementation The steps are done by hardware drivers.
To sum it up in one sentence:The management of the operating system is carried out by first describing and then organizing. The description is to describe each software and hardware as a structure, and then organize these structures for management.

Guess you like

Origin blog.csdn.net/Djsnxbjans/article/details/129027995