@@ -644,7 +644,7 @@ bool CLRLifoSemaphore::WaitForSignal(DWORD timeoutMs)
644
644
645
645
_ASSERTE (timeoutMs != 0 );
646
646
_ASSERTE (m_handle != nullptr );
647
- _ASSERTE (m_counts.waiterCount != (UINT16)0 );
647
+ _ASSERTE (m_counts.VolatileLoadWithoutBarrier (). waiterCount != (UINT16)0 );
648
648
649
649
while (true )
650
650
{
@@ -680,7 +680,7 @@ bool CLRLifoSemaphore::WaitForSignal(DWORD timeoutMs)
680
680
}
681
681
682
682
// Unregister the waiter if this thread will not be waiting anymore, and try to acquire the semaphore
683
- Counts counts = m_counts;
683
+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
684
684
while (true )
685
685
{
686
686
_ASSERTE (counts.waiterCount != (UINT16)0 );
@@ -719,7 +719,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs)
719
719
_ASSERTE (m_handle != nullptr );
720
720
721
721
// Acquire the semaphore or register as a waiter
722
- Counts counts = m_counts;
722
+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
723
723
while (true )
724
724
{
725
725
_ASSERTE (counts.signalCount <= m_maximumSignalCount);
@@ -762,7 +762,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
762
762
}
763
763
764
764
// Try to acquire the semaphore or register as a spinner
765
- Counts counts = m_counts;
765
+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
766
766
while (true )
767
767
{
768
768
Counts newCounts = counts;
@@ -809,7 +809,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
809
809
ClrSleepEx (0 , false );
810
810
811
811
// Try to acquire the semaphore and unregister as a spinner
812
- counts = m_counts;
812
+ counts = m_counts. VolatileLoadWithoutBarrier () ;
813
813
while (true )
814
814
{
815
815
_ASSERTE (counts.spinnerCount != (UINT8)0 );
@@ -868,7 +868,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
868
868
}
869
869
870
870
// Try to acquire the semaphore and unregister as a spinner
871
- counts = m_counts;
871
+ counts = m_counts. VolatileLoadWithoutBarrier () ;
872
872
while (true )
873
873
{
874
874
_ASSERTE (counts.spinnerCount != (UINT8)0 );
@@ -893,7 +893,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
893
893
#endif // _TARGET_ARM64_
894
894
895
895
// Unregister as a spinner, and acquire the semaphore or register as a waiter
896
- counts = m_counts;
896
+ counts = m_counts. VolatileLoadWithoutBarrier () ;
897
897
while (true )
898
898
{
899
899
_ASSERTE (counts.spinnerCount != (UINT8)0 );
@@ -934,7 +934,7 @@ void CLRLifoSemaphore::Release(INT32 releaseCount)
934
934
_ASSERTE (m_handle != INVALID_HANDLE_VALUE);
935
935
936
936
INT32 countOfWaitersToWake;
937
- Counts counts = m_counts;
937
+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
938
938
while (true )
939
939
{
940
940
Counts newCounts = counts;
0 commit comments