<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Self() doesn't have to lock slots AS LONG AS in AssignSlot:<BR>
<BR>
SUBARRAY (new_slots^, 0, n) := slots^;<BR> slots := new_slots;<BR><BR>occurs in the order written.<BR>
That SUBARRAY() := finishes before slots := runs.<BR>
Aggressively compilers/processors need not execute these in the order written.<BR>
<BR>
Do we have a way to guarantee that?<BR>
<BR>
Something like:<BR>
SUBARRAY (new_slots^, 0, n) := slots^;<BR>> MemoryBarrier();<BR>
slots := new_slots;<BR><BR>
?<BR>
<BR>
MemoryBarrier on Windows is implemented as one "special" instruction -- for x86, AMD64, and IA64.<BR>
Those implementations are portable to any OS running those architectures.<BR>
Though they aren't expressed in a portable form (x86 inline assembly and C compiler intrinsincs).<BR>
In particular:<BR>
<BR>
winnt.h:<BR>
amd64:<BR>
#define MemoryBarrier __faststorefence<BR><BR>
x86:<BR>
FORCEINLINE<BR>VOID<BR>MemoryBarrier (<BR> VOID<BR> )<BR>{<BR> LONG Barrier;<BR> __asm {<BR> xchg Barrier, eax<BR> }<BR>}<BR><BR>
ia64:<BR>
#define MemoryBarrier __mf<BR><BR>
<BR>
- Jay<BR>
<BR> </body>
</html>