C volatile variables and Cache Memory

前端 未结 7 1482
滥情空心
滥情空心 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 21:02

    using the _Uncached keyword may help in embedded OS , like MQX

    #define MEM_READ(addr)       (*((volatile _Uncached unsigned int *)(addr)))
    #define MEM_WRITE(addr,data) (*((volatile _Uncached unsigned int *)(addr)) = data)
    

提交回复
热议问题