当前位置:网站首页>Instruction rearrangement, happens before, as if serial
Instruction rearrangement, happens before, as if serial
2022-07-29 01:07:00 【SnnnSn~】
There are certain restrictions on instruction rearrangement , There are two rules :happens-before、as-if-serial To restrain .
Catalog
One . happens-before
1 Definition
- If operation A happens-before B, that A The execution result of will be right B so , and A The execution order of must be in B Before .
- There is... Between the two operations happens-before Relationship , It doesn't mean that Java The specific implementation of the platform must be in accordance with happens-before Execute in the order specified by the relationship ⾏. If the execution after reordering ⾏ result , And press happens-before Relationship to hold ⾏ Result ⼀ Cause , Then the instructions can be reordered .
2. understand
From the perspective of programmers : It provides a memory structure similar to strong memory for programmers , Easy to program .
Stand in the editor and processor manufacturers : Without affecting the correct results , You can let editors and processor manufacturers optimize .
3. Specific rules
- Rules of procedure sequence : Every operation of a thread ,happens-before Any subsequent operation in the thread .
- Monitor lock rules : Unlocking a lock ,happens-before Then lock the lock .
- volatile Variable rule : To a volatile Domain writing ,happens-before In any follow-up to this volatile Domain reading .
- Transitivity : If A happens-before B, And B happens-before C, that A happens-before C.
- start() The rules : If the thread A Perform the operation ThreadB.start()( Start thread B), So thread A Of ThreadB.start() operation happens-before Thread B Any operation in .
- join() The rules : If the thread A perform ThreadB.join() And return successfully , be B Any operation in should happens-before Thread A from ThreadB.join() Operation successful return .
Two .as-if-serial The rules
as-if-serial Semantic meaning means : No matter how reorder ( Compiler and processor to improve parallelism ),( Single thread ) The execution result of the program cannot be changed . compiler ,runtime And the processor must comply as-if-serial semantics .
In order to observe as-if-serial semantics , Compilers and processors Do not reorder operations that have data dependencies , Because this reordering will change the execution result . however , If there are no data dependencies between operations , These operations can be reordered by the compiler and processor .
边栏推荐
- (完美解决)为什么在train/val/test数据集上用train模式效果都很好,但是在eval模式下全部很差
- dart数组,Map,类型判断,条件判断运算符,类型转换
- State compression DP Mondrian's dream
- Selenium wire obtains Baidu Index
- B站“崩溃”始末 2021.07.13 我们是这样崩的(转载)
- 状态压缩dp-蒙德里安的梦想
- Talk about the cross end technical scheme
- System Verilog common syntax
- 🧐 Table1 | finish your third line watch in one second
- 转:认知亚文化
猜你喜欢

QT静态编译程序(Mingw编译)

递归与分治

ThinkPHP高仿蓝奏云网盘系统程序

进程和线程知识点总结1

Summary of preprocessing methods for time series data
![Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]](/img/e3/496247afdb3ea5b9a9cdb8afb0d41b.png)
Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]
![[web development] basic knowledge of flask framework](/img/79/5ece84552c82e98f5e15fac1ee3335.png)
[web development] basic knowledge of flask framework

In the second round, 1000 okaleido tiger were sold out in one hour after logging in to binance NFT again

Plato launched the LAAS protocol elephant swap, which allows users to earn premium income

NFT 项目的 7 种市场营销策略
随机推荐
Classification prediction | MATLAB realizes time series classification prediction of TCN time convolution neural network
【刷题笔记】从链表中删去总和值为零的连续节点
【commons-lang3专题】005- ObjectUtils 专题
B+ tree~
The method of tracking the real-time market of London Silver
如何执行建设项目的时间影响分析?
🧐 Table1 | finish your third line watch in one second
system verilog常用语法
“index [hotel/jXLK5MTYTU-jO9WzJNob4w] already exists“
数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
[target detection] Introduction to yolor theory + practical test visdrone data set
Univariate function integration 1__ Indefinite integral
小程序毕设作品之微信校园浴室预约小程序毕业设计成品(8)毕业设计论文模板
线程锁及锁的升降级
SystemVerilog join and copy operators
What are the methods to track the real-time market of London Silver?
双链表的定义 ~
Protective copy & stateless
day8
【AD学习】本次海上航行器大赛画pcb图的历程