当前位置:网站首页>Difference Between Concurrency and Parallelism
Difference Between Concurrency and Parallelism
2022-07-30 20:02:00 【a ray of sunshine】
When you learn multithreading, you will encounter a term: concurrency.This is a vocabulary in the operating system. It is necessary to understand the difference between concurrency and parallelism. I have collected several expressions from the Internet to help understand.
One:
Concurrency means that a processor handles multiple tasks at the same time.
Parallelism refers to the simultaneous processing of multiple different tasks by multiple processors or multi-core processors.
Concurrency is logically simultaneous (simultaneous), while parallelism is physically simultaneous.
Let's take an analogy: Concurrency means that one person eats three steamed buns at the same time, while parallelism means that three people eat three steamed buns at the same time.
2:
Parallel (parallel): refers to the simultaneous execution of multiple instructions on multiple processors at the same time.It's as if two people are digging a hole with a shovel each, and after an hour, each person will have a big hole.So no matter from a micro or macro point of view, the two are executed together.

Write image description here
Concurrency: It means that only one instruction can be executed at the same time, but multiple process instructions are rapidly executed in turn, so that it has the effect of multiple processes executing at the same time in the macro, but not at the same time in the micro, just divide the time into several segments, so that multiple processes can be executed alternately quickly.It's like two people using the same shovel and taking turns digging a hole. After an hour, they each dig a smaller hole. If they want to dig two larger holes, it will definitely take two hours.
Write a picture description here

Parallelism exists in multiprocessor systems, and concurrency can exist in both uniprocessor and multiprocessor systems. Concurrency can exist in uniprocessor systems because concurrency is an illusion of parallelism. Parallelism requires programs to be able to simultaneouslyMultiple operations are performed, while concurrency simply requires the program to pretend to perform multiple operations simultaneously (one operation per small time slice, multiple operations switching execution quickly).
Three:
When there are multiple threads in operation, if the system has only one CPU, it is impossible to perform more than one thread at the same time. It can only divide the CPU running time into several time periods.The time period is then allocated to each thread for execution. When the thread code of a period of time is running, other threads are in a suspended state. This method is called Concurrent.
When the system has more than one CPU, the operations of threads may be non-concurrent. When one CPU executes one thread, the other CPU can execute another thread. The two threads do not preempt each other's CPU resources and can be performed simultaneously.We call this method Parallel.
Write image description here
边栏推荐
- Is the iPhone really thirteen incense?The two generations of products are completely compared, perhaps the previous generation is more worth buying
- M3SDA: Moment matching for multi-source domain adaptation
- 如何优化OpenSumi终端性能?
- 推荐系统-排序层-模型(一):Embedding + MLP(多层感知机)模型【Deep Crossing模型:经典的Embedding+MLP模型结构】
- Linux下最新版MySQL 8.0的下载与安装(详细步骤)
- 推荐系统:AB测试(AB Test)
- After MySQL grouping, take the largest piece of data [optimal solution]
- mysql8 installation under linux
- halcon——轮廓线
- Encapsulates a console file selector based on inquirer
猜你喜欢

VBA runtime error '-2147217900 (80040e14): Automation error

HCIP --- 企业网的三层架构

推荐系统:开源项目/工具【谷歌:TensorFlow Recommenders】【Facebook:TorchRec】【百度:Graph4Rec】【阿里:DeepRec和EasyRec】

移动web开发01

【无标题】多集嵌套集合使不再有MultipleBagFetchException

MySQL mass production of data

【Node实现数据加密】

推荐系统:AB测试(AB Test)

MySQL database - DQL data query language

普通的int main(){}没有写return 0;会怎么样?
随机推荐
[c语言]二维数组动态分配内存
【MindSpore】多卡训练保存权重问题
基于人脸的常见表情识别——模型搭建、训练与测试
【无标题】多集嵌套集合使不再有MultipleBagFetchException
Different lower_case_table_names settings for server (‘1‘) and data dictionary (‘0‘) 解决方案
el-input 只能输入整数(包括正数、负数、0)或者只能输入整数(包括正数、负数、0)和小数
[Ask] SQL statement to calculate the sum of column 2 by deduplicating column 1?
网络层协议------IP协议
Zabbix 5.0 监控教程(一)
Encapsulates a console file selector based on inquirer
LeetCode 0952.按公因数计算最大组件大小:建图 / 并查集
【flink】报错整理 Could not instantiate the executor. Make sure a planner module is on the classpath
推荐系统:AB测试(AB Test)
明解C语言第五章习题
一文2500字手把手教你配置Jenkins自动化邮件通知
Face-based Common Expression Recognition (2) - Data Acquisition and Arrangement
MySQL database - DQL data query language
How to install and use PostgreSQL 14.4
【视频】极值理论EVT与R语言应用:GPD模型火灾损失分布分析
ResNet18-实现图像分类