当前位置:网站首页>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
边栏推荐
- Applymiddleware principle
- Raspberry pie 4B installation tensorflow2.0[easy to understand]
- Harbor webhook从原理到构建
- Whether lending a bank card to others constitutes a crime
- Question: what professional qualities should test engineers have?
- Unittest框架中测试用例编写规范以及如何运行测试用例
- 全局过滤器(处理时间格式)
- 華為設備配置大型網絡WLAN基本業務
- MySQL IN 和 NOT IN () 空列表报错
- Node version manager NVM installation and switching
猜你喜欢

名创拟7月13日上市:最高发行价22.1港元 单季净利下降19%

The first anniversary of the data security law, which four major changes are coming?

Numpy的矩阵

妙啊!MarkBERT

英特爾實驗室公布集成光子學研究新進展

Unittest 框架介绍及第一个demo

【AI资讯月刊】350+资源大盘点!6月不容错过的资料和动态,都都都在这里啦!<附下载>

Node version manager NVM installation and switching

Shangtang entered the lifting period: the core management voluntarily banned and strengthened the company's long-term value confidence

Combination of Oracle and JSON
随机推荐
Wechat applet development - user authorization to log in to "suggestions collection"
技术分享 | Linkis参数介绍
Paxos 入门
openinstall:微信小程序跳转H5配置业务域名教程
CPI教程-异步接口创建及使用
BAIC bluevale: performance under pressure, extremely difficult period
Continuous delivery -pipeline getting started
In June 2022, it was the first programming language?!
CVPR 2022 | Virtual Correspondence: Humans as a Cue for Extreme-View Geometry
Internal control of fund managers
流动性质押挖矿系统开发如何制作,dapp丨defi丨nft丨lp流动性质押挖矿系统开发案例分析及源码
TMUX usage
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
Huawei Equipment configure les services de base du réseau WLAN à grande échelle
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
Network security learning notes 01 network security foundation
redis中value/set
Numpy的矩阵
Nordic nrf52832 flash download M4 error
8 best practices to protect your IAC security!