Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix MemoryBarrier
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Aug 10, 2016
1 parent 519dcde commit a0597da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/vm/win32threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,10 +1263,10 @@ void ThreadpoolMgr::AdjustMaxWorkersActive()
}

PriorCompletedWorkRequests = totalNumCompletions;
PriorCompletedWorkRequestsTime = currentTicks;
NextCompletedWorkRequestsTime = currentTicks + ThreadAdjustmentInterval;
CurrentSampleStartTime = endTime;
MemoryBarrier();
MemoryBarrier(); // flush previous writes (especially NextCompletedWorkRequestsTime)
PriorCompletedWorkRequestsTime = currentTicks;
CurrentSampleStartTime = endTime;;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/vm/win32threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,9 @@ class ThreadpoolMgr
if (CLRThreadpoolHosted())
return false;

MemoryBarrier();
DWORD priorTime = PriorCompletedWorkRequestsTime;
DWORD requiredInterval = NextCompletedWorkRequestsTime - priorTime; // fences above read
DWORD priorTime = PriorCompletedWorkRequestsTime;
MemoryBarrier(); // read fresh value for NextCompletedWorkRequestsTime below
DWORD requiredInterval = NextCompletedWorkRequestsTime - priorTime;
DWORD elapsedInterval = GetTickCount() - priorTime;
if (elapsedInterval >= requiredInterval)
{
Expand Down

0 comments on commit a0597da

Please sign in to comment.