当前位置:网站首页>Two threads execute i++ 100 times respectively, and the possible values obtained
Two threads execute i++ 100 times respectively, and the possible values obtained
2022-06-22 09:10:00 【Dream of Han and Tang Dynasties】
Two threads execute each 100 Time i++, Possible values obtained
Maximum 200, minimum value 2
The process of obtaining a minimum :
- Threads 1: stay CPU0 perform , From memory 0 To register RegX. At this time, the memory is memory = 0.
- Threads 2: stay CPU1 perform , From memory 0 To register RegY, perform 99 Secondary self addition operation , This may be written back to memory . The first 99 Time calculation completed , Write back to memory , At this time, the memory is memory = 99.
- Threads 1: Start the first 1 Secondary self addition , And write back to memory . At this time, the memory is memory = 1.
- Threads 2: From memory ( This is the case memory = 1) To register RegY, Completion of 100 Secondary self addition , The result is RegY = 2, Before writing back to memory , Threads 1 The following section has been completed 5 Step .
- Threads 1: From memory ( This is the case memory = 1) To register RegX, Finish the rest 99 Secondary self addition , here RegX = 100, And then write it back to memory , here memory = 100.
- Threads 2: take RegY = 2 Write back to memory , Final memory = 2.
i=100, Two threads execute each 50 Time i--, Possible values obtained
Maximum 98, minimum value 0
The process of obtaining the maximum value :
Reference resources
- https://blog.csdn.net/zhangrui_fslib_org/article/details/50311195
- https://wenku.baidu.com/view/233e49f483eb6294dd88d0d233d4b14e85243e02.html
- CPU Cache consistency
- Cache consistency protocol
- Explanation of cache consistency
- Cache consistency protocol : Strongly recommend
- CPU How to cache consistency MESI Protocols to address visibility
边栏推荐
- 版本问题导致“无法定位程序输入点OPENSSL_sk_new_reserve于动态链接库C:\Users...\libssl-1_1-x64.dll”
- Development error reporting record
- 面试突击59:一个表中可以有多个自增列吗?
- 一学就会的tensorflow断点续训(原理+代码详解)
- Solidity from introduction to practice (6)
- Php+mysqli create a table, read multiple items, add, modify and query a complete instance
- Matrix decomposition
- How much do you know about the required encryption industry terms in 2022?
- Php+sql get the field name and detailed attributes of MySQL data table
- 开发报错记录
猜你喜欢

User insight into the video industry in January 2022: active users began to pick up under the influence of holidays

Solidity from introduction to practice (IV)

【Tensorboard】所有雷区都踩,一文解决你所有问题

12 yuan sharing mode

面试突击59:一个表中可以有多个自增列吗?

让你轻松上手【uni-app】

Report: in the technical field, men are more likely to get job interviews

Troubleshooting various errors when Navicat for MySQL connects to MySQL database

Manually mining XSS vulnerabilities

Solid from entry to practice (end)
随机推荐
无线路由攻击和WiFi密码破解实战[渗透技术]
[path planning] auxiliary points and multi segment Bessel smoothing RRT
Thread. Source code analysis of start() method
Xshell远程服务器tensorboard/visdom的本地可视化方法【亲测一步有效】
The version problem caused "unable to locate the program input point openssl\u sk\new\u reserve in the dynamic link library c:\users... \libssl-1\u 1-x64.dll"
函数总结(1)
It is hoped that more and more women will engage in scientific and technological work
[detailed explanation] point multiplication and cross multiplication of neural network matrix (pytorch version)
Kali Trojan invades win7 system
希望越来越多的女性从事科技工作
WebRTC系列-网络传输之IceConfig及stunPing失败处理
[target detection] | detection error mechanism why object detectors fail: investigating the influence of the dataset
Alibaba big fish SMS interface PHP version, simplified version Alibaba big fish SMS sending interface PHP instance
17 iterator mode
新型冠状病毒疫情
Luogu p4292 [wc2010] reconstruction plan
Flask blog practice - user management
三个不同线程顺序打印ABC十种写法【并发编程JUC】
Monaco editor format JSON, SQL
Luogu p4557 [jsoi2018] war