<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Is there some really good article
(better than the wikipedia
<a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Memory_barrier">https://en.wikipedia.org/wiki/Memory_barrier</a>) on<br>
<br>
- memory barrier<br>
vs <br>
- cache coherency <br>
vs<br>
interlocked<br>
?<br>
<br>
<br>
<br>
On 22/08/2020 16:57, Jonas Maebe via fpc-devel wrote:<br>
</div>
<blockquote type="cite"
cite="mid:323cd0fb-2655-09dc-ce99-d2931f5e2963@freepascal.org">Very
important: InterlockedExchange is not a memory barrier, except on
x86.</blockquote>
<br>
<blockquote type="cite"
cite="mid:323cd0fb-2655-09dc-ce99-d2931f5e2963@freepascal.org">It's
not a semaphore/signal, it's just a field. It will never be
<pre class="moz-quote-pre" wrap="">instantaneous since it can only have an effect once the target thread
actually tries to read it. Wrapping it in a bunch of synchronisation
primitives will make the whole system slower with no real benefit.
</pre>
</blockquote>
<tt><span class="code"><span class="sym"><br>
</span></span></tt>I guess the "Terminate" field is actually
about cache coherency.<br>
<br>
But I could not find any reliable info, if <br>
- a memory barrier is needed for cache coherency. <br>
- a memory barrier even affects cache coherency <br>
<br>
I would assume that InterLocked will make sure (maybe as side
effect) that there is cache coherency ?<br>
I.e. it makes sure (on all platforms) that the particular value that
it did set, will be immediately visible to all other threads (if
they use interlocked.... to read it)?<br>
<br>
At least that is what I always thought. If that is not the case, I
have a lot of code to fix...<br>
I acknowledge that <br>
- a value set with InterlockedExchange
by one thread<br>
- may not be visible in other threads, if the access it *without*
InterlockedExchange
<br>
- does not affect the visibility of any other memory between
threads.<br>
<br>
How far off am I ?<br>
<br>
<br>
<tt><span class="code"><span class="sym"></span></span></tt>
</body>
</html>