当前位置:网站首页>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
边栏推荐
- Oracle和JSON的結合
- Matrix of numpy
- 开发说,“ 这个不用测,回归正常流程就行 “,测试人员怎么办?
- Mingchuang plans to be listed on July 13: the highest issue price is HK $22.1, and the net profit in a single quarter decreases by 19%
- 8 best practices to protect your IAC security!
- Tianrunyun, invested by Tian Suning, was listed: its market value was 2.2 billion Hong Kong, and its first year profit decreased by 75%
- TEMPEST HDMI泄漏接收 4
- 2022/6/30学习总结
- Graduation season · advanced technology er
- Huawei Equipment configure les services de base du réseau WLAN à grande échelle
猜你喜欢

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)

Applymiddleware principle

全局过滤器(处理时间格式)

Jd.com renewed its cooperation with Tencent: issuing class A shares to Tencent with a maximum value of US $220million

CVPR22 |CMT:CNN和Transformer的高效结合(开源)

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

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

TEMPEST HDMI泄漏接收 5

金融壹账通拟7月4日香港上市:2年亏近30亿 市值蒸发超90%

关于Keil编译程序出现“File has been changed outside the editor,reload?”的解决方法
随机推荐
Internal control of fund managers
为什么一定要从DevOps走向BizDevOps?
Spam filtering challenges
The idea runs with an error command line is too long Shorten command line for...
Introduction to unittest framework and the first demo
Packet mode and three streaming modes in SDP protocol
Can solo be accessed through IPv6?
JS date format conversion method
(POJ - 1456) supermarket
CVPR 2022 | self enhanced unpaired image defogging based on density and depth decomposition
Huawei Equipment configure les services de base du réseau WLAN à grande échelle
Yoda unified data application -- Exploration and practice of fusion computing in ant risk scenarios
Export and import of incluxdb on WIN platform
redis中value/hush
Exposure:A White-Box Photo Post-Processing Framework阅读札记
2022/6/30学习总结
sdp 协议中的packetization-mode方式和三种流传输模式
redis中value/String
Global filter (processing time format)
VScode快捷键(最全)[通俗易懂]