<div dir="ltr">Say two Gambit threads that execute concurrently in two different OS threads, are communicating by mutating a structure. E.g.<div><br></div><div>Global:</div><div><br></div><div>(define itc-state:set? #f)</div><div>(define itc-state:message #f)</div><div><br></div><div><br></div><div>Thread 1 does:</div><div>(set! itc-state:message ..something..)</div><div>(set! itc-state:set? #t)</div><div><br></div><div><br></div><div>And thread 2 polls:</div><div>(do loop ()</div><div><br></div><div>(if itc-state:set? (act-on! itc-state:message))</div><div><br></div><div>(loop))</div><div><br></div><div><br></div><div>Is any direct polling of structures between OS threads illegal in SMP Gambit, or what is the intended way for this to be coherent?</div><div><br></div><div><br></div><div>(If this was ordinary C code, on a weakly ordered architecture, the worry would be that the |itc-state:set?| update would reach the other CPU core before the |itc-state:message| update reached it and that the program hence would enter into an undefined state - and for this reason programs do a write barrier between.)</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-11-13 21:44 GMT+08:00 Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca" target="_blank">feeley@iro.umontreal.ca</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Nov 11, 2017, at 5:13 PM, Adam <<a href="mailto:adam.mlmb@gmail.com">adam.mlmb@gmail.com</a>> wrote:<br>
><br>
> Dear Marc,<br>
><br>
> Are there any constraints on what underlying hardware platform SMP Gambit can work on, e.g. architectures with strong memory ordering (AMD64) versus architectures with weak memory ordering (ARM64)?<br>
<br>
</span>No foreseen constraints.<br>
<span class=""><br>
><br>
> Does Gambit export any memory barrier primitive?<br>
<br>
</span>No<br>
<span class=""><br>
><br>
> Do any particular Gambit primitives imply a memory barrier, so these are abstracted away from the user?<br>
<br>
</span>mutex-lock! and there might be others…<br>
<span class=""><br>
><br>
> E.g. (thread-send! t (list 1 2 3)) would imply a memory barrier on weakly ordered systems, if t is being executed on another OS thread, so that when the message is received on the other side, Gambit has automatically ensured that the structure is actually accessible on the receiving end?<br>
<br>
</span>This should work.  If it doesn’t please submit an issue report.<br>
<span class="HOEnZb"><font color="#888888"><br>
Marc<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> (<a href="https://en.wikipedia.org/wiki/Memory_ordering#Runtime_memory_ordering" rel="noreferrer" target="_blank">https://en.wikipedia.org/<wbr>wiki/Memory_ordering#Runtime_<wbr>memory_ordering</a>)<br>
><br>
> Will appreciate a lot to understand how to manage this.<br>
><br>
> Thanks!<br>
> Adam<br>
<br>
</div></div></blockquote></div><br></div>