The basic process of process scheduling

what is a process

A process is an abstraction of a running program by the operating system, that is, a running program is a process.
The process is the basic unit of resource allocation by the operating system.
For example, if we open our computer task manager, we will see many running processes.
insert image description here

process management

Process management is generally divided into two steps
1. Describe a process: use a structure/class (also called a process control block) to represent the information of the process.
2. Organize these processes: organize these structures/objects through a certain data structure.

main property of a structure or class

pid

A unique identifier for each process.

memory pointer

The current process is using that part of the memory (the process needs to consume certain hardware resources when running, such as memory).

file descriptor table

It records the hardware resources used when the process is running, generates a file, and organizes a file description table according to a certain data structure.

Attributes of worker process scheduling

  • Process state
    Ready state: The process is ready to be executed on the CPU.
    Blocked state: The process cannot be executed on the CPU temporarily.
  • Process priority
    Scheduling between processes has priority, and high priority is frequently scheduled.
  • Process Context
    A context is an "archive record" that describes where a process executes.
    Record the running results when the concurrent execution leaves the CPU, and execute again according to the recorded results after the process returns to the CPU next time.
  • The credit information of the process
    counts how long each process has been executed on the CPU.
    It can be used as a reference for future process scheduling.

concurrency

The running of the program depends on the CPU of the computer. The CPU has a concept called the number of cores (one core can only execute one program at a time). Our computer generally does not have more than 20 cores, but my task manager above shows that there are so many programs running. How does the computer do it? This is the concurrency concept we will understand below.

parallel

At the same time, two cores execute two processes at the same time, then these two processes are executed concurrently.

concurrency

A core first executes process 1, then executes process 2, and then executes process 3, so that each process is executed and the switching frequency is so fast that our human eyes cannot detect it, so in our view, programs 1, 2, and 3 are "executed at the same time".

Under the control of the operating system, the CPU performs multi-process execution in a concurrent manner.
In general, concurrency and parallelism are collectively referred to as concurrency.

Guess you like

Origin blog.csdn.net/st200112266/article/details/129578848