Easy to understand multi-process and multi-thread

Multi-process and multi-thread

Process basis

Processes and procedures

What is a program ?

  • Ordered collection of instructions and data

  • Generalized problem-solving logic set

  • An executable binary file in a narrow sense

  • Is a static concept

What is a process?

  • The program runs as a process

  • When the program is executed once, a process is generated. When the execution ends, the process ends

  • Process is the smallest unit of operating system allocation of resourcesAllocate memory, files. . .

Thread

Thread is the smallest unit of CPU scheduling

A process can contain several threads, at least one

The relationship between program and process

Procedure—>Recipe

Process—"A dish

A program can spawn multiple processes

Parallel and concurrency

Serial number Happening the difference
parallel Multiple processes or multiple threads Multi-core, multiple CPU
Concurrent Multiple processes or multiple threads Single core

Single process


Concurrent

Because the switching is fast, there is an illusion of simultaneous execution


Parallel
Multi-core and multiple CPUs to achieve true simultaneous execution

Guess you like

Origin blog.csdn.net/hhb442/article/details/108076407