C volatile and Cache Memory

 

  1. Volatile keyword tells compiler that the variable references shouldn't be optimized and should be read as programmed in the code.

  2. Cache is controlled by cache hardware transparently, hence when processor issues an address, it doesn't know whether the data is coming from cache or the memory.

     

volatile 关键字仅仅在编译阶段有效。

运行过程中cpu读到的数据,都需要根据mmu来确定。对于dev属性的address,每次读都会从address重新读取。

对于mem属性的address ,读取的数据如果cache命中,数据来自cache,如果cache miss,会从address中读取。

 

memory 属性参考:https://www.cnblogs.com/smartjourneys/p/6844145.html 

memory分为normal memory和device memory,两种类型的Memory有各自的属性,除了下面介绍的几种属性外,还有其他一些杂项属性

2.1 Normal Memory

  • Shareable  Normal Memory

可以被所有的PE访问, 包括:Inner Shareable, and Outer Shareable;

  • Non-shareable Normal Memory

只能被唯一的PE访问;

  • Cacheability属性

Normal Memory具有Cacheability属性,此属性包含如下三种:

(1)Write-Through Cacheable:同时写入cache与内存;

(2)Write-Back Cacheable:直接更新cache,闲时再更新到内存;

(3) Non-cacheable:无cache,不需要更新cache,直接更新内存

2.2 Device Memory

Device Memory具有如下几种属性:

  • Gathering 或者non Gathering (G or nG)

这个特性表示对多个memory的访问是否可以合并,如果是nG,表示处理器必须严格按照代码中内存访问来进行,不能把两次访问合并成一次。例如:代码中有2次对同样的一个地址的读访问,那么处理器必须严格进行两次read transaction

  • Re-ordering (R or nR)

这个特性用来表示是否允许处理器对内存访问指令进行重排。nR表示必须严格执行program order。

  • Early Write Acknowledgement (E or nE)

PE访问memory是有问有答的(更专业的术语叫做transaction),对于write而言,PE需要write ack操作以便确定完成一个write transaction。为了加快写的速度,系统的中间环节可能会设定一些write buffer。nE表示写操作的ack必须来自最终的目的地而不是中间的write buffer。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值