[JAVAee] The basic process of process scheduling

Table of contents

process

process management

Process Description - PCB

process management

process scheduling


process

A process is a program that is running

When we open the task manager, we can see that some programs are running. He is the process 

process management

A process is the basic unit for the system to allocate hardware resources. In a running computer, there are many processes. As shown in the above figure, there are already 88 background processes.

So how does the computer manage them?

The core idea for the management of the computer squadron process is: describe first, then manage.

First of all, we need to understand the information of each process, and clarify what its role is, so that we can better schedule and manage it, so that our computer can run more efficiently.

Process Description - PCB

Each process will have a corresponding PCB. The whole process is Process Control Block, process control block, pcb is usually in the form of a structure.

The main confidence of a process PCB is probably:

  • PID, Process Identifier. Process control character, just like everyone's student number. It is used to mark and distinguish the current process, but when the process is terminated, the pid will disappear. But it may be used by another newly started process use.
  • Memory pointer, which describes what the memory resource of the process is like in the memory pointer. It stores the instructions and data of the executable file, and also keeps the result data of the intermediate process.
  • The file descriptor table describes the files used by the process, what files are opened, what files are closed, and what files are in use

 Of course, in addition to these, PCB has many other attributes.

                                                                    (PID)

process management

Computers usually use a series of data structures to manage processes, which is convenient for querying, adding and deleting processes at any time.

When we look at the process table in the task manager, it is like traversing the structure once, and when the corresponding start and stop processes will create a PCB structure and add it to this structure and transfer the corresponding PCB from the structure delete and release.

process scheduling

In the computers we use now, we can open multiple processes and use them at the same time. While playing songs, while browsing the page, QQ or WeChat is still sending you messages.

All these seem to happen at the same time, but in fact, a CPU in a computer can only execute one process. How can a single-core computer run multiple processes at the same time as mentioned above?

This is about process scheduling.

Regarding the operating system, the processes are always executed back and forth, each process executes for a short period of time, and the execution repeatedly jumps between each process.

Execute process A to do some work, then go to process B to do some work, and suddenly go to process C for execution.

This is the concurrency between processes , taking turns on a CPU. Because the switching speed of the CPU is very fast, we can't feel his switching at a macro level.

Just like the light tube at home, it seems to be always on, but in fact it has been flickering all the time. It's just that our naked eyes can't feel it.

For a similar concept of parallelism , two different processes are running on two CPUs at the same time.

On the current operating system, when scheduling processes, it may be in a concurrent or parallel manner. But in the end, their scheduling effects are actually consistent.

Guess you like

Origin blog.csdn.net/weixin_67719939/article/details/131865690