📜  并发和并行的区别

📅  最后修改于: 2021-09-14 02:28:10             🧑  作者: Mango

并发:
并发性与同时处理多个任务的应用程序有关。并发是一种通过使用单个处理单元来减少系统响应时间的方法。并发会造成并行的错觉,但实际上任务的块并不是并行处理的,而是在应用程序内部,一次处理多个任务。它不会在一项任务开始之前完全结束它。
并发是通过中央处理单元(CPU)上进程的交错操作或换句话说通过上下文切换来实现的。这就是它就像并行处理的基本原理。它增加了一次完成的工作量。

在上图中,我们可以看到有多个任务在同时取得进展。该图显示了并发性,因为并发性是一次处理大量事物的技术。

平行度:
并行性与将任务划分为看似同时或并行处理的较小子任务的应用程序相关。它用于通过使用多个处理器来提高系统的吞吐量和计算速度。它使单个顺序 CPU 能够“看似”同时做很多事情。

并行导致一个进程中的中央处理单元和输入输出任务与另一进程的中央处理单元和输入输出任务重叠。而在并发中,通过将一个进程的输入输出活动与另一个进程的 CPU 进程重叠来提高速度。

在上图中,我们可以看到任务被划分为同时或并行处理的更小的子任务。该图显示了并行性,即同时运行线程的技术。

并发和并行的区别:-

S.NO Concurrency Parallelism
1. Concurrency is the task of running and managing the multiple computations at the same time. While parallelism is the task of running multiple computations simultaneously.
2. Concurrency is achieved through the interleaving operation of processes on the central processing unit(CPU) or in other words by the context switching. While it is achieved by through multiple central processing units(CPUs).
3. Concurrency can be done by using a single processing unit. While this can’t be done by using a single processing unit. it needs multiple processing units.
4. Concurrency increases the amount of work finished at a time. While it improves the throughput and computational speed of the system.
5. Concurrency deals lot of things simultaneously. While it do lot of things simultaneously.
6. Concurrency is the non-deterministic control flow approach. While it is deterministic control flow approach.
7. In concurrency debugging is very hard. While in this debugging is also hard but simple than concurrency.