当前位置:网站首页>Kernel synchronization mechanism
Kernel synchronization mechanism
2022-07-01 11:21:00 【Daily enlightenment】
Some basic concepts about synchronization theory :
A critical region (critical area): Code snippet for accessing or manipulating shared data , It can be simply understood as synchronized The part in braces ( Atomicity )Competitive conditions (race conditions): Two threads have the execution right of the critical section at the same time
Data inconsistency :data unconsistency Data corruption caused by competitive conditions
Sync (synchronization): avoid race conditions
lock : The means to synchronize ( Door lock , Behind the door is the critical area , Only one thread is allowed to exist ) Locking and unlocking must be atomic
Atomicity : An indivisible operation like an atom
Orderliness : Prohibit command rearrangement
visibility : Modifications within a thread , Another thread is visible
Common methods of kernel synchronization :
- Atomic manipulation : The kernel is similar to AtomicXXX, be located <linux/types.h>
- spinlocks : Supported by assembly in the kernel cas, be located <asm/spinlock.h>
- Read write spin : Be similar to ReadWriteLock, Can read at the same time , Only one can write , When I read it, it's a shared lock , When I write, it's exclusive
- Semaphore : Be similar to Semaphore(PV operation down up operation , Possession and release ) Heavyweight lock , The thread will enter wait, Suitable for long-term holding of locks
- Read and write semaphores :downread upread downwrite upwrite ( Write more than one , You can write in sections , Less use )( Section lock )
- mutex (mutex): Special semaphores ( Binary semaphore )
- Completion variables : Special semaphores (A Signal to B,B Waiting on the completion variable ) vfork() Wake up the parent process by completing the variable at the end of the child process Be similar to (Latch)
- BKL: Big kernel lock
- Sequential lock (2.6): Read and write spinlocks that threads can suspend , Sequence counter ( from 0 Start , Add... As you write (+1), After writing, release (+1), I found the singular before reading , There is a write thread , wait for , The sequence before and after reading is the same , Note that there is no write thread break )
- No preemption :preempt_disable()
- Memory barrier : see volatile
边栏推荐
- Nordic nrf52832 flash download M4 error
- Export and import of incluxdb on WIN platform
- MySQL in and not in() empty list error
- Numpy的矩阵
- Activity workflow engine
- 树莓派4B安装tensorflow2.0[通俗易懂]
- 转义字符串
- Neurips 2022 | cell image segmentation competition officially launched!
- CVPR 2022 | self enhanced unpaired image defogging based on density and depth decomposition
- Spam filtering challenges
猜你喜欢

“目标检测”+“视觉理解”实现对输入图像的理解及翻译(附源代码)

redis配置环境变量

Global filter (processing time format)

node版本管理器nvm安装及切换

为什么一定要从DevOps走向BizDevOps?

京东与腾讯续签合作:向腾讯发行A类股 价值最高达2.2亿美元

Huawei Equipment configure les services de base du réseau WLAN à grande échelle

Face detection and recognition system based on mtcnn+facenet

Yoda unified data application -- Exploration and practice of fusion computing in ant risk scenarios

英特尔实验室公布集成光子学研究新进展
随机推荐
Neurips 2022 | cell image segmentation competition officially launched!
No statements may be issued when any streaming result sets are open and in use on a given connection
BAIC bluevale: performance under pressure, extremely difficult period
Intel Labs annonce de nouveaux progrès en photonique intégrée
持续交付-Pipeline入门
CAD如何设置标注小数位
索引失效的几种情况
Openinstall: wechat applet jump to H5 configuration service domain name tutorial
The developer said, "this doesn't need to be tested, just return to the normal process". What about the testers?
力扣(LeetCode)181. 超过经理收入的员工(2022.06.29)
JS日期格式化转换方法
Face detection and recognition system based on mtcnn+facenet
Y48. Chapter III kubernetes from introduction to mastery -- pod status and probe (21)
Share the method of how to preview PSD format and PSD file thumbnail plug-in [easy to understand]
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
華為設備配置大型網絡WLAN基本業務
CVPR 2022 | self enhanced unpaired image defogging based on density and depth decomposition
The first anniversary of the data security law, which four major changes are coming?
Mysql的四个隔离级别是如何实现的 (简要)
妙啊!MarkBERT