免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12345678
最近访问板块 发新帖
楼主: ethantsien

[C] 一道题 --- 学C就要关注更底层的东西 [复制链接]

论坛徽章:
3
15-16赛季CBA联赛之山东
日期:2016-10-30 08:47:3015-16赛季CBA联赛之佛山
日期:2016-12-17 00:06:31CU十四周年纪念徽章
日期:2017-12-03 01:04:02
发表于 2012-10-17 12:47 |显示全部楼层
回复 67# gvim


    “安心经历这人世的一招”... 应为"安心经历这人世的一遭".

论坛徽章:
1
摩羯座
日期:2013-12-19 10:04:07
发表于 2012-10-17 17:05 |显示全部楼层
回复 66# gvim


    谢谢 我懂了

论坛徽章:
5
狮子座
日期:2013-08-20 10:12:24午马
日期:2013-11-23 18:04:102015年辞旧岁徽章
日期:2015-03-03 16:54:152015亚冠之德黑兰石油
日期:2015-06-29 18:11:1115-16赛季CBA联赛之新疆
日期:2024-02-21 10:00:53
发表于 2012-10-17 17:51 |显示全部楼层
回复 70# captivated


    x86就是,这函数根本只用到了两个寄存器而已……

论坛徽章:
0
发表于 2012-10-17 18:41 |显示全部楼层
据说有些编译器就有这么牛. Paul McKenney 讲RCU的一篇文章:http://lwn.net/Articles/262464/

However, it is not sufficient to only enforce ordering at the updater, as the reader must enforce proper ordering as well. Consider for example the following code fragment:

  1 p = gp;
  2 if (p != NULL) {
  3   do_something_with(p->a, p->b, p->c);
  4 }
Although this code fragment might well seem immune to misordering, unfortunately, the DEC Alpha CPU [PDF] and value-speculation compiler optimizations can, believe it or not, cause the values of p->a, p->b, and p->c to be fetched before the value of p! This is perhaps easiest to see in the case of value-speculation compiler optimizations, where the compiler guesses the value of p, fetches p->a, p->b, and p->c, then fetches the actual value of p in order to check whether its guess was correct. This sort of optimization is quite aggressive, perhaps insanely so, but does actually occur in the context of profile-driven optimization.


底层软件的话,考虑多nasty的东西都无所谓。不过给用户态程序造成这样的混乱实在太蛋疼了。

@塑料袋 元芳,你怎么看?

论坛徽章:
0
发表于 2012-10-17 22:00 |显示全部楼层
不可能一遍学习C,还一遍把汇编的特性都学完整了,太蛋疼了……

论坛徽章:
2
程序设计版块每日发帖之星
日期:2015-06-17 22:20:00每日论坛发贴之星
日期:2015-06-17 22:20:00
发表于 2012-10-17 22:44 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP