当前位置:网站首页>spin lock和mutex使用场景的差异
spin lock和mutex使用场景的差异
2022-07-30 10:38:00 【a Explorer】
在单核CPU下,spin lock没有意义,只会影响正常线程响应;使用mutex虽然会在“挂起”和“运行”两个队列间切换,但提高了系统整体的响应比。
多核CPU下,spin lock在多个和核心上的轮询时间是可以忽略的,使用spin lock避免了因为队列切换导致的时间消耗。
现代操作系统的做法,多核的环境中,在实现mutex时,如果lock操作后,进行断在的轮询(spin lock),超过这段时间后,使用传统的mutex阻塞(加入挂起队列)。如果程序可预测的中阻塞的时间较短,可以主动使用spin lock。
边栏推荐
- [HarmonyOS] [ARK UI] How to double-click the return key to exit in HarmonyOS ets language
- unity3d C#语言基础(继承)
- 神经网络学习笔记4——自动编码器(含稀疏,堆叠)(更新中)
- Mysterious APT Attack
- PyQt5 - draw sine curve with pixels
- Drools 规则引擎一文读懂
- js对数组操作移动进行封装
- 2022全球数字经济大会人工智能专场:AI安全受高度关注
- 梅科尔工作室-看鸿蒙设备开发实战笔记七——网络应用开发
- Flink_CDC construction and simple use
猜你喜欢
![[Deep Learning] (Problem Record) <What do I get by calculating the gradient of a variable> - Linear Regression - Small Batch Stochastic Gradient Descent](/img/28/834aac16859fd26ab69de30f5fed55.png)
[Deep Learning] (Problem Record)
- Linear Regression - Small Batch Stochastic Gradient Descent 
实现web实时消息推送的7种方案

Meikle Studio-Look at Hongmeng Device Development Practical Notes 7-Network Application Development

【云原生】-Docker安装部署分布式数据库 OceanBase

AB测试 总结归纳

Linux内核设计与实现(十)| 页高速缓存和页回写

还在用Swagger?我推荐这款零代码侵入的接口管理神器

神经网络学习笔记3——LSTM长短期记忆网络

系统设计精选 | 基于FPGA的CAN总线控制器的设计(附代码)

Re17: Read the paper Challenges for Information Extraction from Dialogue in Criminal Law
随机推荐
Meikle Studio - see the actual combat notes of Hongmeng device development 4 - kernel development
【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
Neural Network Study Notes 3 - LSTM Long Short-Term Memory Network
XYplorer 23多语言,最好的管理软件之一
Database transactions, JDBC operations and data types
unity3d C#语言基础(继承)
梅科尔工作室-看鸿蒙设备开发实战笔记七——网络应用开发
MySQL database maintenance
真正懂经营管理的CIO具备哪些特质
AB测试 总结归纳
OC- about alloc and dealloc (haven't started writing yet)
湖仓一体电商项目(一):项目背景和架构介绍
Alibaba Cloud OSS Object Storage
Meikle Studio-Look at Hongmeng Device Development Practical Notes 7-Network Application Development
关于verilog的时延研究
Drools 规则引擎一文读懂
(BUG record) No module named PIL
MySQL | Subqueries
Flink_CDC construction and simple use
jmeter接口压力测试(一)