public void FastThread() { interestedF.Store(1, MemoryOrder.Relaxed); victim.Store(0, MemoryOrder.Release); while (true) { if (interestedS.Load(MemoryOrder.Relaxed) != 1) { break; } if (victim.Load(MemoryOrder.Relaxed) != 0) { break; } RE.Yield(); } RE.Assert(_threadsPassed == 0, $"Fast thread entered while slow thread in critical section! ({_threadsPassed})"); _threadsPassed++; interestedF.Store(0, MemoryOrder.Relaxed); _threadsPassed--; }
public void Atomic_Int_Store_Should_Fail() { var atomicInteger = new Atomic<int>(int.MaxValue); Assert.Throws<InvalidOperationException>(() => atomicInteger.Store(int.MinValue, MemoryOrder.Acquire)); Assert.Throws<NotSupportedException>(() => atomicInteger.Store(int.MinValue, MemoryOrder.Consume)); }
public void Thread0() { x.Store(1, MemoryOrder.Relaxed); x.Store(2, MemoryOrder.Relaxed); }
public void Atomic_Bool_Store_Should_Fail() { var atomicBoolean = new Atomic<bool>(true); Assert.Throws<InvalidOperationException>(() => atomicBoolean.Store(false, MemoryOrder.Acquire)); Assert.Throws<NotSupportedException>(() => atomicBoolean.Store(false, MemoryOrder.Consume)); }
public void Atomic_Int_Store_Should_Success(int initialValue, int storeValue, MemoryOrder order) { var atomicInteger = new Atomic<int>(initialValue, order); atomicInteger.Store(storeValue, order); Assert.Equal(storeValue, atomicInteger.Value); }
public void Atomic_Bool_Store_Should_Success(bool initialValue, bool storeValue, MemoryOrder order) { var atomicBoolean = new Atomic<bool>(initialValue, order); atomicBoolean.Store(storeValue, order); Assert.Equal(storeValue, atomicBoolean.Value); }
public void Atomic_Long_Store_Should_Fail() { var atomicLong = new Atomic<long>(long.MaxValue); Assert.Throws<InvalidOperationException>(() => atomicLong.Store(long.MinValue, MemoryOrder.Acquire)); Assert.Throws<NotSupportedException>(() => atomicLong.Store(long.MinValue, MemoryOrder.Consume)); }
public void Atomic_Long_Store_Should_Success(long initialValue, long storeValue, MemoryOrder order) { var atomicLong = new Atomic<long>(initialValue, order); atomicLong.Store(storeValue, order); Assert.Equal(storeValue, atomicLong.Value); }
public void Thread1() { x0.Store(1, ActiveConfig.MemoryOrder); y0 = x1.Load(ActiveConfig.MemoryOrder); }
public void Thread0() { a.Store(1, ActiveConfig.MemoryOrder); }