[Linux] Process Concept I - Operating System Concept and Von Neumann Architecture

img

Halo, this is Ppeua. I usually update C language, C++, data structure algorithms... If you are interested, please follow me! You won't be disappointed.


Insert image description here

A computer is composed of two parts: hardware + software . The hardware-related part is the von Neumann architecture , and the software-related part is the operating system .

1. Von Neumann architecture

Nowadays, most computers (laptops, servers, etc.) comply with the von Neumann architecture. The actual model details are more complicated. This is a simple model after abstraction. Its structural model is :

bf9b4e7ba426b5cf8416ca9e992684c

In this picture, red is the data transmission signal, while black is the control signal.

The input devices are: keyboard, mouse, hard disk and other devices

Output devices are: monitors, printers, hard drives and other devices

The arithmetic unit and controller are collectively called CPU

The memory here refers to the memory, not the hard disk.

Why is it designed this way?

The speed of input devices and output devices is much slower than the speed of the CPU. The speed of the memory is between the two.

It can be seen from the barrel effect that performance is often determined by shortcomings.

image-20230826170459034

If the CPU is directly connected to the input and output devices, the CPU will be waiting for the IO device most of the time, and the CPU cannot be used effectively.

The addition of memory as a medium can solve this problem to a large extent and improve CPU utilization.

So why not choose the fastest cache?

According to the storage pyramid, the higher up, the higher the price and the faster the speed. If all the fastest caches are used, computers will not be popularized because of their high cost.

In one sentence: all devices can only deal with memory

Regarding the von Neumann architecture, we can try to understand it from the following two examples

  1. After you log into QQ, you can chat with your friends. (It does not involve the network transmission level)

    First, the keyboard is used as an input device. We input data, and then the data is put into the memory and processed by the CPU. After processing, it is put into the output device, which is the network card at this time .

    Send to your friend's computer.

    Similarly, his computer also meets this architecture. The network card serves as an input device. After receiving the message, it puts the message into the memory. After the CPU processes the message, it displays it on the output device screen .

7bdcc5af99426bfbb2949a57573a0c9

  1. Transfer files via qq

    First, the hard disk is used as an input device. We input data, and then the data is put into the memory and processed by the CPU. After processing, it is put into the output device, which is the network card at this time .

    Send to your friend's computer.

    Similarly, his computer also meets this architecture. The network card is used as an input device. After receiving the file data, it puts the file data into the memory. After the CPU processes the file data, it stores it on the hard disk of the output device .

1aa497326af28e1501e009b51e52fa5

2. Operating system concept

The operating system is a piece of management software . The von Neumann architecture above shows the hardware level. But how do each piece of hardware work together? This is the meaning of the operating system.

Why do we need an operating system?

  1. Help users manage software and hardware resources
  2. In order to provide users with an efficient operating environment, people who use computers can be roughly divided into two types of people, one is ordinary users, and the other is programmers. The former use mostly software developed by programmers. And programmers are programmers. They are the people who actually use the operating system.

Because the operating system does not trust users and encapsulates itself, most of the time we cannot see its details. In order to maintain its own security and provide services to users, users can only access it through the interface it provides. That is, system calls interface

In other words: **Any access to the operating system can only be completed through system calls. **This ensures the security and stability of the system.

How to manage the operating system?

Let’s first imagine a scenario:

How does the principal manage every student in school?

First, describe the data and record each student's information in a specific format. Then organize the data and put it into an excel table for easy management. Then if you want to find a certain student, just search according to specific attributes.

The same is true in operating systems. Each object that needs to be managed first describes the data in a specific format , and then organizes it through the data structure .

So**, in the operating system, managing any object can be converted into additions, deletions, checks and modifications of a certain type of data structure.**

We will talk about how to do it specifically later.

The address book we wrote before is just a process of describing each person first and then organizing it. In some ways, it is the same as the operating system.

//描述
struct Person{
    
    
  int age;
  int tel;
  string address;
};
//组织
struct Contact
{
    
    
  Person p[100];  
};

6bb2ef0104c16313701e6047fb28c4b

What are we doing when we call the printf() function?

Each function that calls hardware has a system call interface encapsulated inside it, so it also accesses the driver and hardware through the system call interface, and finally displays it on the screen.
image-20230905164632777

Guess you like

Origin blog.csdn.net/qq_62839589/article/details/132792583