2 ms·
The classic case where you need to do a cache flush is when you're a JIT writing out native code. Once you've written the instructions into memory you need to c
by pm215 14y ago
The classic case where you need to do a cache flush is when you're a JIT writing out native code. Once you've written the instructions into memory you need to clean the data cache [ie ensure that your changes are made visible to anything 'below' you in the memory hierarchy] and invalidate the icache [ie throw away any info you have], so that when the CPU starts to execute instructions from the memory you've just written it doesn't get the stale old versions that might otherwise be in the icache. In fact you only need to clean data out to the point in the memory hierarchy where the icache and the dcache for all your cores come together, which is probably not the same as "write it all really back to system RAM" but is basically indistinguishable from such by the programmer.
NB that x86 maintains coherency between icache and dcache (unlike ARM, say), so you don't need to do this on that CPU architecture.