diff options
author | Tsuda Kageyu <tsuda.kageyu@gmail.com> | 2015-08-18 04:59:24 +0300 |
---|---|---|
committer | Tsuda Kageyu <tsuda.kageyu@gmail.com> | 2015-08-18 04:59:24 +0300 |
commit | b52a484dc67c069b3a074969b29ff3508c38991e (patch) | |
tree | 0a846a16b26e71dcbe967bfb742d773869de08cf | |
parent | 1bab4997916d761d5a61c2cc4e568f3bbb4b4ed9 (diff) |
Add some supplementary comments.
-rw-r--r-- | src/hook.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -442,6 +442,9 @@ static VOID EnterSpinLock(VOID) // Wait until the flag is FALSE. while (InterlockedCompareExchange(&g_isLocked, TRUE, FALSE) != FALSE) { + // No need to generate a memory barrier here, since InterlockedCompareExchange() + // generates a full memory barrier itself. + // Prevent the loop from being too busy. if (spinCount < 32) Sleep(0); @@ -455,6 +458,9 @@ static VOID EnterSpinLock(VOID) //------------------------------------------------------------------------- static VOID LeaveSpinLock(VOID) { + // No need to generate a memory barrier here, since InterlockedExchange() + // generates a full memory barrier itself. + InterlockedExchange(&g_isLocked, FALSE); } |