当前位置:网站首页>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
边栏推荐
- Huawei equipment is configured with large network WLAN basic services
- Mysql的四个隔离级别是如何实现的 (简要)
- Harbor webhook从原理到构建
- 达梦数据冲刺科创板:拟募资24亿 冯裕才曾为华科教授
- 商汤进入解禁期:核心管理层自愿禁售 强化公司长期价值信心
- “目标检测”+“视觉理解”实现对输入图像的理解及翻译(附源代码)
- Global filter (processing time format)
- Can I open a securities account anywhere? Is it safe to open an account
- Jd.com renewed its cooperation with Tencent: issuing class A shares to Tencent with a maximum value of US $220million
- 证券账户销户后果 开户安全吗
猜你喜欢

十年磨一剑:蚂蚁集团可观测性平台 AntMonitor 揭秘

In June 2022, it was the first programming language?!

Unittest框架中跳过要执行的测试用例

2022/6/28学习总结

The project bar on the left side of CodeBlocks disappears, workspace automatically saves the project, default workspace, open the last workspace, workspace (Graphic tutorial, solved)

Spam filtering challenges

redis配置环境变量

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

关于Keil编译程序出现“File has been changed outside the editor,reload?”的解决方法

英特爾實驗室公布集成光子學研究新進展
随机推荐
tmux使用
No statements may be issued when any streaming result sets are open and in use on a given connection
No statements may be issued when any streaming result sets are open and in use on a given connection
Wechat applet development - user authorization to log in to "suggestions collection"
今天开户今天能买股票吗?在线开户是很安全么?
Harbor webhook从原理到构建
Can I open an account today and buy stocks today? Is it safe to open an account online?
提问:测试工程师应该具备哪些职业素养?
CVPR22 |CMT:CNN和Transformer的高效结合(开源)
sdp 协议中的packetization-mode方式和三种流传输模式
BAIC bluevale: performance under pressure, extremely difficult period
(POJ - 1456) supermarket
微信小程序开发 – 用户授权登陆「建议收藏」
Continuous delivery -pipeline getting started
Internal control of fund managers
Question: what professional qualities should test engineers have?
How to realize the four isolation levels of MySQL (brief)
redis常识
CAD如何设置标注小数位
[buuctf.reverse] 144_[XMAN2018排位赛]easyvm