C volatile variables and Cache Memory

前端 未结 7 1483
滥情空心
滥情空心 2020-11-29 20:17

Cache is controlled by cache hardware transparently to processor, so if we use volatile variables in C program, how is it guaranteed that my program reads data each time fro

7条回答
  •  眼角桃花
    2020-11-29 20:58

    As you say cache is transparent to the programmer. The system guarantees that you always see the value that was last written to if you access an object through its address. The "only" thing that you may incur if an obsolete value is in your cache is a runtime penalty.

提交回复
热议问题