The difference and connection between parallel and concurrency

Parallel (parallel) refers to the same moment, two or more times occur at the same time.

Concurrency refers to the same time interval (same period of time), two or more times occurring at the same time.


connect:

Macroscopically, parallelism and concurrency both mean processing multiple requests at the same time.


Concurrency: The essence is that a physical CPU (or multiple physical CPUs) is multiplexed among several programs. Concurrency is to enforce multi-user sharing of limited physical resources to improve efficiency.
Parallelism: Refers to the occurrence of two or more events or activities at the same time. In a multiprogramming environment, parallelism enables multiple programs to execute simultaneously on different CPUs at the same time.



Concurrency is running multiple programs on the same cpu at the same time (not really at the same time, but at the same time, because the cpu switches between multiple programs).
Features: 1. Single processor; 2. Logically simultaneous processing



In parallel, each CPU runs a program.
Features: 1. Multi-processor, multi-core; 2. Physically simultaneous processing


Make an analogy. Concurrency is like one person (cpu) feeding 2 children (programs), each feeding a mouthful in turn, on the surface, both children are eating. In parallel, 2 people feed 2 children, and both children are eating at the same time.

Use parallel concurrency to analyze specific problems:
In a uniprocessor system, the characteristics of multiprogramming are:
1. Multi-channel. Several independent programs are stored in the memory at the same time.
2. Macroscopically parallel. Several programs entered the system at the same time, and they were all running. They started running one after another, but none of them finished running.
3. Microscopically serial. In fact, each program takes turns using the CPU, executing programs alternately.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324589031&siteId=291194637