what is the difference between cache invalidate and cache flush?
If one function has updated variables that are cached, does it need to invalidate it or flush it? For other functions that need to see the new values of the variables updated (and invalidated/flushed) by the first one, do they need to flush the cache or invalidate it when reading? Thanks for help.
See other thread for your specific case: It is probably not so much about caches, but more about volatiles.
A cache invalidate simply marks the cache contents as invalid. So the next time you access data, you will get what is in memory. A cache flush writes back data from cache into memory. These two will differ only when memory contents get out of sync with cache contents, which will happen only when you have DMA or a 2nd processor writing to the same memory location.