当前位置:网站首页>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 .
边栏推荐
- 进程和线程知识点总结 2
- PLATO上线LAAS协议Elephant Swap,用户可借此获得溢价收益
- The method of tracking the real-time market of London Silver
- 【commons-lang3专题】005- ObjectUtils 专题
- 散列表 ~
- Station B "crashed" from beginning to end 2021.07.13 we collapsed like this (Reprint)
- day8
- SystemVerilog-连接和复制运算符
- Selenium wire obtains Baidu Index
- system verilog常用语法
猜你喜欢

新拟态个人引导页源码

How to carry out engineering implementation of DDD Domain Driven Design

可视化全链路日志追踪

mysql存储过程 实现创建一张表(复制原表的结构新建的表)

Hash table~

Wechat campus bathroom reservation applet graduation design finished product (8) graduation design thesis template

Educational Codeforces Round 132 (Rated for Div. 2)【A~C】

面试突击69:TCP 可靠吗?为什么?

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

小程序毕设作品之微信校园浴室预约小程序毕业设计成品(6)开题答辩PPT
随机推荐
How to create a custom 404 error page in WordPress
Wechat campus bathroom reservation applet graduation design finished product (5) assignment
18张图,直观理解神经网络、流形和拓扑
dart数组,Map,类型判断,条件判断运算符,类型转换
[unity] configure unity edit C as vscode
ActiveMQ基本详解
面试突击69:TCP 可靠吗?为什么?
【刷题笔记】链表内指定区间反转
电子招标初学者指南
Charles -- 从0-1教你如何使用抓包工具
[Yugong series] go teaching course in July 2022, an array of 020 go containers
Deep learning | matlab implementation of TCN time convolution neural network spatialdropoutlayer parameter description
[web development] basic knowledge of flask framework
双链表的定义 ~
B+ tree~
如何执行建设项目的时间影响分析?
Educational Codeforces Round 132 (Rated for Div. 2)【A~C】
指令重排、happens-before、as-if-serial
Wechat campus bathroom reservation for the finished product of applet graduation design (7) mid term inspection report
正则表达式