当前位置:网站首页>Membarrier (personal learning and understanding)
Membarrier (personal learning and understanding)
2022-04-23 05:27:00 【What’smean】
memebarrier It's the realization of Linux Kernel synchronization mechanism , Is a way to ensure the order of memory access ; Similar to the function of locking .
example :
There are two threads writer、reader Running on the Linux On different nuclei of , They all operate on the same circular queue .
writer_index Mark bit for write , Before each write writer_index+1 To write ; Initial value bit 0;
reader_index Mark bit for reading , Before each reading reader_index+1 read ; The initial value is 0;
Conditions :reader_index-writer_index!=1 Can write
writer_index-reader_index!=0 Can be read
if CPU Execute out of order :
( Default initial index All for 0)
writer Check reader_index - writer_index != 1 First writer_index+1, Write again , And before writing reader Find out writer_index-reader_index!=0 , Think you can read , But there is no readable data in the queue .
( Default initial reader_index - writer_index = 1)
Similarly, read first reader_index-1, here writer Find out reader_index - writer_index != 1 Write when you think there is a writable space , Will cause reader The data not read out is writer Write overwrite .
Supplementary knowledge : Disorderly execution : Disorderly execution (out-of-order execution) Refer to CPU It adopts the technology that allows multiple instructions to be sent separately to each corresponding circuit unit for processing without following the sequence specified in the program . example Core The out of order execution engine says that a certain section of the program has 7 Orders , here CPU It will be analyzed according to the idle state of each unit circuit and whether each instruction can be executed in advance , Send the instructions that can be executed in advance to the corresponding circuit immediately .
It's like asking A、B、C Three celebrities wrote banners for the party “ Spring Festival Gala ” Six big words , Write two words each . If at this time on a large piece of paper in order by A Write well " Spring Festival " Then give it to B Write " Get together ", And then by C Write " Evening party ", So what is this A When writing ,B and C Must wait , And in the B When writing C Still have to wait and A It's all right .
But if three people write on three sheets of paper at the same time , that B and C You don't have to wait to write your own at the same time , even to the extent that C and B It's better than A It doesn't matter to write it first ( It's like disorderly execution ), But when they're done, they have to put it on the banner again ( Naturally, it can be done by others , Just like CPU Rearrange cells after out of order execution in ) Press " Spring Festival Gala " In order to hang out .
For the above reasons , Memory masking is introduced into the kernel (membarrier) The concept of , One of the multiple cores sends out a memory mask , Then all other read and write operations of checking the memory segment are stopped , Also have barrier After that c The assembly corresponding to the code , You can't run to barrier Go before .( The above is an old version of membarrier, The new version of the membarrier In each kernel, there are optional rules to follow .)
A kernel performs a similar process after reading and writing fence Instructions , Release after all operations are completed .
Point out if there is a deviation , thank you
版权声明
本文为[What’smean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220544124692.html
边栏推荐
- Basic knowledge of redis
- Output string in reverse order
- What are the most popular recruitment technical skills in 2022? You can't think of it
- 双击.jar包无法运行解决方法
- MySQL series - install MySQL 5.6.27 on Linux and solve common problems
- Blender programmed terrain production
- node中的redis使用--ioredis
- Pandas to_ SQL function pit avoidance guide "with correct code to run"
- 跨域CORS的情缘~
- Laravel database
猜你喜欢

Use of uniapp native plug-ins

4 most common automated test challenges and Countermeasures

2021-11-08

双击.jar包无法运行解决方法

狼叔来找翻译人员了--plato--持续翻译中.....

Good test data management, in the end how to do?

Three methods of list rendering

MFC implementation resources are implemented separately by DLL
![[untitled] Notepad content writing area](/img/0a/4a3636025c3e0441f45c99e3c67b67.png)
[untitled] Notepad content writing area

Graphics.FromImage报错“Graphics object cannot be created from an image that has an indexed pixel ...”
随机推荐
Laravel routing job
Excel 2016 cannot open the file for the first time. Sometimes it is blank and sometimes it is very slow. You have to open it for the second time
Laravel routing settings
node中的redis使用--ioredis
If I am PM's performance, movie VR ticket purchase display
Low code and no code considerations
Fast application fuzzy search
egg的static的前缀是可以修改惹,靴靴
Redis的基本知识
可執行程序執行流程
App Store年交易额100万美元只缴15%佣金,中小开发者心里很矛盾
Laravel [view]
Blender programmed terrain production
Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
2021-10-12
FileReader API file operation
egg中的cors和proxy(づ ̄3 ̄)づ╭~踩坑填坑的过程~ToT~
【openh264】cmake: msopenh264-static
Create process memory management copy_ Mm - processes and threads (IX)
Various situations of data / component binding