Big data technology - the difference between parallelism and concurrency

1. Concurrency


1. Concept


When there are multiple threads operating, if the system has only one CPU, it is impossible to execute more than one thread at the same time. It can only divide the CPU running time into several time periods, and then allocate the time periods to each thread. Execution, while the thread code is running for a period of time, other threads are suspended. . This way we call it concurrent (Concurrent).

2. Features


For uniprocessors – multiple programs happening at the same time


Two, parallel


1. Concept


When the system has more than one CPU, the operations of threads may not be concurrent. When one CPU executes one thread, another CPU can execute another thread. The two threads do not seize CPU resources and can be executed at the same time. This method is called parallel (Parallel).

2. Features


For multiprocessors – multiple programs are happening at the same time


3. The difference and connection between concurrency and parallelism


In the computer operating system, parallelism and concurrency are clearly distinguished, mainly from a microscopic point of view.

Specifically, it refers to the parallelism of the process (in the case of a multiprocessor, multiple processes run at the same time) and concurrency (in the case of a single processor, multiple processes run at the same time interval) .

1. Concurrency and parallelism are two concepts that are similar but different. Parallelism means that two or more events occur at the same time; while concurrency means that two or more events occur within the same time interval.
2. In a multi-programming environment, concurrency means that there are multiple programs running at the same time macroscopically for a period of time, but in a single-processor system, only one program can be executed at a time, so these The program can only be executed alternately in a time-sharing manner.
3. If there are multiple processors in the computer system, these programs that can be executed concurrently can be distributed to multiple processors to realize parallel execution, that is, each processor is used to process a program that can be executed concurrently. , multiple programs can be executed simultaneously.
Parallel >> Concurrent

Guess you like

Origin blog.csdn.net/qq_53142796/article/details/131180835