LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 844|回复: 1

内核代码中的wmb()和rmb()具体做了什么动作?

[复制链接]
发表于 2005-10-12 17:47:41 | 显示全部楼层 |阅读模式
在每个arch底下都有wmb和rmb的函数定义,有的竟然还使用了汇编.
很明显是跟具体的硬件体系结构有关系.

我猜它们应该分别是Write Memory Back 和Read Memory Back的缩写???
是不是就是对cpu cache的回写和重读?
是不是类似于某些DSP上面的_cache_copyback和_cache_invalidate,
但是cache_copyback和cache_invalidate都有2个参数,分别为指定起始地址和字节数.而wmb()和rmb()都没有任何参数,它们具体做了什么呢?不可能cache上的全部都回写和重读吧?

先谢过各位的指教了^_^
发表于 2005-10-13 02:37:10 | 显示全部楼层
wmb() and rmb() prevent the complier to optimize the code. Because after the compiler does optimization, the read and write sequence may be different as the sequence in your code. wmb means write memory barrier and rmd means read memory barrier. Hope this help
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表