【Linux】--First introduction to the operating system

Table of contents

1. Von Neumann architecture

2. Operating system

1. Concept

2. Why do we need an operating system?

3. Operating system

1. Hardware layer

2. Driver layer

3. Operating system layer

4. User layer

(1) User layer 

(2) System call interface 

(3) User operation interface

 4. How to manage

1. Management rules 

2.How to manage 


1. Von Neumann architecture

        Before understanding operating systems, it is important to understand modern computer systems. Modern computer systems have to mention the von Neumann architecture.

         The von Neumann architecture is a memory structure that combines program instruction memory and data memory. The program instruction storage address and the data storage address point to different physical locations in the same memory.

The Von Neumann architecture has three basic principles:

(1) Binary logic

(2) Program storage execution

(3) A computer consists of 5 parts: arithmetic unit, controller, memory, input device, and output device

The following is the storage architecture of modern computer systems: 

  • Input device : Input device is a device for the computer to obtain external information, mainly including keyboard, mouse, and network card.
  • Output device : An output device is a device that presents to the user information obtained from an input device and is displayed after a series of calculations. It mainly includes monitors, printers, etc.
  • Memory : Memory is the memory device of a computer, so memory can store information. There are two types of memory, one is main memory, which is memory, which is the main interaction object of the CPU, and the other is external memory, such as hard disk and floppy disk.
  • Operator : The main function of the operator is to process and operate data and information. It is a component in a computer that performs arithmetic and various logical operations. The basic operations of the arithmetic unit include addition, subtraction, multiplication, division, shift and other operations, which are implemented by the Arithmetic & Logical Unit. The arithmetic unit is mainly composed of arithmetic logic units and registers.
  • Controller : refers to a component that changes the main circuit or control circuit in a specified sequence. It mainly plays the role of controlling the execution of commands and completing the coordination and command of the operation of the entire computer system. The controller is composed of program counter, instruction register, decoding decoder, etc.

Among them, the central processing unit (CPU) includes arithmetic units and controllers. Memory here can be understood as memory. Peripherals need to input or output data and can only write to or read from memory. Input and output are viewed from the perspective of memory. 

How the von Neumann architecture works:

        When the input device receives the data, the data will be stored in the memory. The controller issues instructions to retrieve the data and perform operations. The data is taken out and put into the arithmetic unit for operation. After the operation is completed, the controller issues instructions to store the data and perform operations. Output , data is stored in memory and then output through an output device. ( The instructions of the entire process controller occupy the leading position ).

This process is similar to the process by which humans receive and process output information:

        When the eyes see certain information, the information is stored in the memory device. The brain takes out the information from the memory device, thinks about it, and puts it back into the memory device. The brain controls the memory device to transmit the information to the mouth and express the information. (The brain’s instructions take the lead in this process).

        Regarding the data flow when using QQ chat, from a pure hardware perspective:

        The qq software is in the memory. Entering a message into qq through the keyboard means inputting the message into the memory. The CPU needs to encrypt and calculate the message, which requires adding copy network-related content. The CPU reads the data from the memory (memory) and then performs calculations. , write it back to the memory after processing, and then send it to the network through the network card. The network forwards it to the other party's network card.


        After reaching the other party's network card, the data enters the input device and reads the data from the input device into the memory. In this way, the qq program reads the network card content into qq, decrypts it, then removes the header information, writes it to the memory, and finally refreshes it to on the other party’s monitor.

 Peripherals and the CPU both deal directly with memory at the data level.

2. Operating system

1. Concept

The operating system is software specifically designed to manage software and hardware resources. The operating system is on the disk or peripheral before it is started. The operating system is meaningful only when the operating system is loaded into the memory.

2. Why do we need an operating system?

The significance of the existence of an operating system is to manage software and hardware resources. It provides users with a stable, efficient and safe operating environment.

3. Operating system

1. Hardware layer

 The components of the von Neumann architecture are computer hardware, and these hardware all comply with the von Neumann architecture:

2. Driver layer

It is impossible for programmers to deal directly with these hardware, so computer scientists have installed a layer of software on top of these hardware, which can control the hardware according to the instructions entered by the user, and determine when and how much data the memory reads from the input device. Which refresh method is used to refresh the buffer to the output device, etc. This layer of software is the operating system. The operating system provides user programs with a better, simpler, and clearer model of the computer. In other words, the operating system is equivalent to an intermediate layer, providing respective excuses for the user layer and hardware, shielding the differences between different applications and hardware, and achieving a unified standard.

The operating system does not directly interact with the underlying hardware. Therefore, a driver layer is added between the operating system and the underlying hardware. The driver layer enables the operating system to control the underlying hardware devices. It provides operating interfaces for external devices to the operating system and implements device drivers. The operating system can operate regardless of the internal implementation of the device, and only needs to call the driver interface.

The driver is a medium between the operating system and the hardware, achieving two-way communication, that is, conveying the functions of the hardware device itself to the operating system, and also conveying the standard instructions of the operating system to the hardware device, thereby achieving seamless communication between the two. seam connection. The operating system only needs to care about when the data is read, not how the data is read, which means the decoupling between the operating system and the hardware is completed.

So how did the driver become this medium? It is used as a medium by installing hardware drivers. Hardware devices such as keyboard, mouse, hard disk, monitor, motherboard, graphics card, sound card, network card, printer, etc. all have their own drivers. The driver is a configuration file written by the hardware manufacturer based on the operating system.

The operating system is equivalent to the brain of the computer architecture, and the driver is equivalent to the limbs to control various hardware.

3. Operating system layer

Since the operating system is used to manage software and hardware resources, but there are so many software and hardware resources, how to manage them? Management can be divided into the following four types according to resources:

  • Memory management: memory space allocation and recycling, address translation, memory space expansion, memory sharing, storage protection
  • Driver management: classification, update, deletion, etc. of device drivers
  • File management: file storage space management, directory management, file operation management and file protection
  • Process management: scheduling of processes

4. User layer

(1) User layer 

The operating system serves users, so above the operating system is the user layer. The user layer is the graphical interface on Windows systems and the command line on Linux:

(2) System call interface 

 But will the operating system deal directly with the user layer? No, because the operating system does not trust users. In order to protect itself, a system call interface is added between the operating system and the user layer to communicate between the user and the kernel space. The system call interface is from a development perspective. The operating system will appear as a whole to the outside world, but it will expose part of its interface for upper-layer development. This part of the interface provided by the operating system is called the system call interface. :

(3) User operation interface

System calls do not interact directly with programmers. The system call interface is relatively complex. The prerequisite for programmers to use the system call interface to manage hardware every time is to have a certain degree of understanding of the system. Therefore, some powerful people have encapsulated the system call interface and formed a library, such as GUN C&C++ third-party library, which is presented in language. This has a user operation interface, which is conducive to secondary development by higher-level users or developers. :

 After understanding the relationship between each level, it is not difficult to understand the computer architecture diagram:

 4. How to manage

1. Management rules 

 Since the operating system is management software, how to manage software and hardware resources? 

  • Managers and the managed do not interact directly
  • Management strategy is to make various decisions based on the attributes and data of resources
  • Managers and the managed do not interact directly, so how do managers know the data? It is known through the executor of the decision.

For example, in the management of a zoo, the director serves as the manager, the animal administrator serves as the executor, and the animals serve as the managed. The director does not deal directly with the animals. Strategies are formulated based on the type and status of the animals. The director obtains the data and information of the animals through the executor of the policy, that is, the animal administrator.

 

 Therefore, when managing, you need to consider whether to do it and how to do it, and then do it. The director makes decisions as a manager, but the director does not execute them. Instead, the animal administrator, the executor, executes the decisions. Therefore, the executor's task is to implement the manager's decision.

2.How to manage 

Under normal circumstances, the director does not stay in the zoo, so how does the director manage the animals without seeing them? If an animal exhibition needs to be held, how does the director decide which animals are in the best condition to participate in the exhibition? The director did not see these five animals in the best condition, so how did he manage them? ----------Managed according to attributes and data

The attributes and data of these animals will be organized into information, such as animal appearance characteristics table, animal health status table, animal residence information table, this is the description information:

Each animal has these three tables. These three tables describe how a zoo director manages each animal through the management of these three tables. These three tables are called abstract structures in C language and object-oriented in C++. To manage all animals in the zoo, the director can organize the information of all animals. How to organize it? This requires the use of data structures, such as sequential lists, linked lists, trees, and hashes. Each organizational method has its own advantages and disadvantages, and you can choose the appropriate organizational method for organizing. If organized in the form of a linked list:

 After organizing the information tables of all animals, the management of all animals becomes the addition, deletion, checking and modification of the linked list. The creation, deletion and modification of animals can be operated on the linked list.

The data structure is the core of the operating system, so from the above we can abstract how the operating system is managed - first describe, then organize

Guess you like

Origin blog.csdn.net/gx714433461/article/details/127981929