Skip to content

Instantly share code, notes, and snippets.

@JustasMasiulis
Created April 3, 2019 10:06
Show Gist options
  • Save JustasMasiulis/64b713cd85d50b190f0d348fea1462a4 to your computer and use it in GitHub Desktop.
Save JustasMasiulis/64b713cd85d50b190f0d348fea1462a4 to your computer and use it in GitHub Desktop.
int64_t MiSetPfnTbFlushStamp(_MMPFN *pfn, char flushStamp, BOOL pfnLocked)
{
if(pfnLocked)
pfn->u2.TbFlushStamp = flushStamp;
else // CAS loop
while(true) {
auto old = pfn->u2;
auto new = old;
new.TbFlushStamp = flushStamp;
if(_InterlockedCompareExchange(&pfn->u2.Lock, new.EntireField, old.EntireField) == old.EntireField)
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment