-
Volatile keyword tells compiler that the variable references shouldn't be optimized and should be read as programmed in the code.
-
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。