Multithreading – what is the point of cache consistency?

Is it useful from a practical point of view to provide cache consistency on CPUs like x86? I understand that the idea is to make the kernel update complete on one core and can be displayed immediately on all other cores This is a useful attribute However, if it is not written in assembly language, you can't rely on it too much, because the compiler can store variable assignments in registers instead of writing them to memory This means that explicit steps must also be taken to ensure that what is done in other threads is visible in the current thread So, from a practical point of view, what is cache consistency?

Solution

Imagine you doing this:

lock(); //some synchronization primitive e.g. a semaphore/mutex
globalint = somevalue;
unlock();

Without cache consistency, the last unlock () will have to ensure that globalint can now be seen everywhere, so all you need to do is write it to memory and let the hardware do it A software solution will keep which memory exists in which cache and which kernel ensures that they are atomically synchronized in some way

If you can find a software solution to track all the memory in the cache that needs to be synchronized, you will receive a reward, which is more efficient than the current hardware solution

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>