zoukankan      html  css  js  c++  java
  • __asm__ __volatile__("": : :"memory")

    memory 强制gcc编译器假设RAM所有内存单元均被汇编指令修改,这样cpu中的registers和cache中已缓存的内存单元中的数据将作废。cpu将不得不在需要的时候重新读取内存中的数据。这就阻止了cpu又将registers,cache中的数据用于去优化指令,而避免去访问内存。


        The GCC manual says using 'asm volatile' prevents the asm instruction from being 'movedsignificantly' and adding 'memory' to the clobber list prevents GCC from keeping memory values cached in registers across the assembler instruction, but also says 'GCC will perform some optimizations across a volatile asm instruction' but doesn't explain what.

       

    1)   __asm__用于指示编译器在此插入汇编语句。

    2)  __volatile__用于告诉编译器,严禁将此处的汇编语句与其它的语句重组合优化。即:原原本本按原来的样子处理这这里的汇编。
    3) 
     
    memory强制gcc编译器假设RAM所有内存单元均被汇编指令修改,这样cpu中的registers和cache中已缓存的内存单元中的数据将作废。cpu将不得不在需要的时候重新读取内存中的数据。这就阻止了cpu又将registers,cache中的数据用于去优化指令,而避免去访问内存。
    4) 
      "":::表示这是个空指令。barrier()不用在此插入一条串行化汇编指令。
  • 相关阅读:
    软件工程导论P53,习题2.4
    视图和数据表的区别
    无法从“object”转换为“string”
    Oracle 密码重置
    Struts2 上传下载
    Spring 事务管理
    JSP 指令和动作
    JS 禁用回车、后退事件、form 表单不可编辑
    关于 in 和 exist 的理解
    Oracle clob 操作函数
  • 原文地址:https://www.cnblogs.com/liang123/p/6325376.html
Copyright © 2011-2022 走看看