Von Neumann Architecture and Process Concept Understanding

Table of contents

1. Let’s talk about hardware first

1. Preliminary understanding of von Neumann architecture

2. Understand the collaboration between modules

2. Talk about software again

1. Why there is an operating system

2. How the operating system manages hardware and software resources

3. Talk about the process again

1. What is a process

2. How to understand the process

3. How Linux manages processes

Write at the end:


1. Let’s talk about hardware first

1. Preliminary understanding of von Neumann architecture

The computers I know now are all composed of hardware, and they all follow this system:

Let's first slowly understand the von Neumann architecture:

1) What does memory refer to?

Storage refers to memory, and our hardware such as disks are input and output devices.

2) Input devices: keyboard, camera, microphone, disk, network card...

3) Output devices: monitors, player hardware, disks, network cards...

Input and output devices are also called external devices, also known as peripherals.

4) Calculator: Perform calculation tasks (arithmetic operations, logical operations) on the data we input

5) Controller: To control our computing hardware process to a certain extent

We collectively refer to these two as the central processing unit, or CPU.

And these five components are independent entities. want their system to work,

The various hardware units must be connected by "wires", which we call buses: 1. System bus, 2. IO bus.

2. Understand the collaboration between modules

Or this picture:

Let me talk about the conclusion first:

First, the input device is delivered to the memory, and the central processing unit takes the data from the memory, and then performs calculations internally, and then writes the calculation result back to the memory, and then refreshes the data to the input device. This is the flow of data in the von Neumann system.

Let's talk about storage:

Generally speaking, the larger the storage capacity, the slower the speed will be. It is precisely because of this that we need memory as a buffer in our system, so that the slow peripherals and the fast central processing unit can better interact with data through the memory.

Speaking of the collaboration between so many modules, who will realize their collaboration? operating system.

2. Talk about software again

Our computers have QQ, WeChat, browsers, etc., how does the computer know when to use them? So we need something to coordinate them as a whole. That is, the operating system,

The operating system is a management software that can manage hardware and software.

1. Why there is an operating system

The whole computer is a layered structure, look at such a picture:

From bottom to top, there are hardware and drivers first. If all hardware needs to be used by software, it needs to be equipped with corresponding drivers. We can understand them as software that directly deals with hardware, and then the operating system at the top. What we need to focus on later is process management and file management.

Back to the original topic, why do we need an operating system?

1) The operating system helps users manage these hardware and software resources. (means)

2) In order to provide users with a good (stable, efficient, safe) operating environment. (Purpose)

There are all kinds of data in the operating system, but the operating system does not trust all users! Therefore, in order to ensure the security of its own data and to ensure the provision of services to users, the operating system provides users with access to call in the form of interfaces to obtain internal resources of the operating system.

So what is an interface? The Linux operating system is essentially written in C language, so the so-called interface is actually its own internal function call implemented by C language, which we call system call. However, all access to the operating system can only be done through system calls.

So look back at that picture, and then up is the system call system call interface.

Then there is the user operation interface, which includes the familiar shell shell, and then lib, that is, the library. Because the system call is still relatively complicated, some languages ​​​​will package it into a library for us to use.

For any language, if they want to use the hardware directly or indirectly, they must go through the operating system, and through the operating system, they must use the system call interface.

Then the above is the overall layered structure of the computer.

2. How the operating system manages hardware and software resources

Let's first understand what management is:

1) The manager and the person being managed do not need to meet each other (just like in schools, as students, we generally do not meet with the principal, and in companies, we generally do not always meet with the boss (I didn’t say that in small companies) )

2) How can managers manage well without seeing the managed? The core lies in management information. As long as managers get management information, they can make management decisions in the future. The essence of management is to manage people through the management of 'data'.

3) Neither the manager nor the managed can see each other, how to get the corresponding data? (First add a concept: what is a manager? We generally divide all things in the world into two types, one is decision-making and the other is execution. For example: what are you eating tonight? Let’s eat noodles. This is a decision-making; I’m going to cook noodles now. This is execution. The decision-making is actually the manager, and the person who executes is the managed. But in our daily life, decision-making and execution are basically one.) Managers need to get corresponding data.

so!

When the operating system is being managed, does it need to see the software and hardware? No, how can the operating system get their status data? Taking hardware as an example, the operating system obtains data through drivers.

The operating system must follow the strategy of "describe first, then organize" to manage anything, use a structure to describe an object, and then organize it with a data structure, so that a state can be achieved: in operation In the system, managing any object can eventually be transformed into adding, deleting, checking and modifying a certain data structure.

Conclusion: How is the operating system managed?

Describe first, organize later.

3. Talk about the process again

1. What is a process

A program that has been loaded into memory is called a process.

Let's write a process under Linux and take a look:

We simply write a program and run it:

 

Then we copy an SSH channel and check the process:

ps axj | head -1 && ps axj | grep process

So in fact, the running program is called a process.        

2. How to understand the process

An operating system can not only run one process, but also run multiple processes at the same time.

The operating system must manage the process, so how to manage the process? Describe first, organize later.

When any process is loaded into memory, when forming a real process, the operating system needs to first create a structure object used to describe the process——PCB, process ctrl block——process control block.

Here comes the question, how should the process be described in this way? Describe a thing with a collection of various attributes. So the so-called PCB is actually a collection of process attributes. So PCB is a structure:

struct PCB {

        the number of the process,

        the state of the process,

        the priority of the process,

        ... ... 

}

The system will create a corresponding PCB object for the process according to the PCB type of the process.

So what is a process, is the process a PCB? No, the process is actually:

Process = kernel PCB data structure object + code and data of the corresponding program

The process PCB, of course, contains all the attributes describing the process. In this way, the operating system does not manage your code and data, it only needs to manage the process PCB. In this way, all management operations of the operating system on the process become additions, deletions, checks, and modifications to a data structure such as PCB.

3. How Linux manages processes

Earlier we understood what a process looks like, so how does the Linux operating system organize and manage processes?

The PCB under the Linux operating system is: task_struct (the process is actually called a task by some), and the process task_struct is organized in the form of a basic double-linked list in the Linux kernel. 

As for what the task_struct looks like, then, if you want to know what happens next, let’s listen to the next chapter to decompose~

Write at the end:

The above is the content of this article, thank you for reading.

If you feel that you have gained something, you can give the blogger a like .

If there are omissions or mistakes in the content of the article, please private message the blogger or point it out in the comment area~

Guess you like

Origin blog.csdn.net/Locky136/article/details/132121034