当前位置:网站首页>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
边栏推荐
- JSP -- Introduction to JSP
- WTL 自绘控件库 (CQsCheckComboxBox)
- varnish入门
- [untitled]
- Create cells through JS (while loop)
- Modèle axé sur le domaine DDD (III) - gestion des transactions à l'aide de Saga
- Pandas to_ SQL function pit avoidance guide "with correct code to run"
- SQL Server检索SQL和用户信息的需求
- After NPM was upgraded, there was a lot of panic
- JSON.
猜你喜欢

Requirements for SQL server to retrieve SQL and user information

JS array common methods

C test calls the paddlesharp module to recognize pictures and words

Various situations of data / component binding

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

Graphics. Fromimage reports an error "graphics object cannot be created from an image that has an indexed pixel..."

Devops life cycle, all you want to know is here!

Modèle axé sur le domaine DDD (III) - gestion des transactions à l'aide de Saga

Basic use of sqlyog
![[untitled] Notepad content writing area](/img/0a/4a3636025c3e0441f45c99e3c67b67.png)
[untitled] Notepad content writing area
随机推荐
Output string in reverse order
The introduction of lean management needs to achieve these nine points in advance
[the background color changes after clicking a line]
Implementation of resnet-34 CNN with kears
Create cells through JS (while loop)
Click the Add button - a box appears (similar to adding learning experience - undergraduate - Graduate)
Why can't V-IF and V-for be used together
Laravel [view]
Simple and basic use of switch and if
4 most common automated test challenges and Countermeasures
what is wifi6?
Error handling mechanism of the strongest egg framework in history
史上最强egg框架的error处理机制
PIP free export with path (@ file: / / /) notes
TSlint注释忽略错误和RESTful理解
phphphphphphphp
Intel SGX preliminary learning and understanding notes (continuously updated)
Laravel routing job
Wbpack configuring production development environment
Various situations of data / component binding