Esempio n. 1
0
        public void SimpleAtomicityTest2()
        {
            racyvariable = 0;

            Thread t = new Thread((Object irrelevant) =>
            {
                ChessAPI.TraceEvent("doing child ops");
                ChessAPI.PreemptionDisable();
                ChessAPI.PreemptionDisable();
                ChessAPI.PreemptionEnable();
                ChessAPI.PreemptionEnable();
                racyvariable++;
            });

            t.Start();

            ChessAPI.TraceEvent("doing parent ops");
            ChessAPI.PreemptionDisable();
            racyvariable++;
            ChessAPI.PreemptionEnable();

            t.Join();

            Assert.AreEqual(2, racyvariable);
        }