static void Foo() { NekaraManagedClient nekara = RuntimeEnvironment.Client; nekara.Api.StartTask(1); Console.WriteLine("Foo/Acquire()"); lck.Acquire(); Console.WriteLine("Foo/ContextSwitch()"); nekara.Api.ContextSwitch(); int lx1 = x; Console.WriteLine("Foo/ContextSwitch()"); nekara.Api.ContextSwitch(); int lx2 = x; Console.WriteLine("Foo/Release()"); lck.Release(); // nekara.Api.Assert(lx1 == lx2, "Race!"); if (!(lx1 == lx2)) { bugfound = true; } Console.WriteLine("Foo EndTask"); nekara.Api.EndTask(1); }
static void Foo(int taskId) { nekara.StartTask(taskId); Console.WriteLine("Foo({0})/Acquire()", taskId); lck.Acquire(); Console.WriteLine("Foo({0})/ContextSwitch():0", taskId); nekara.ContextSwitch(); x = taskId; Console.WriteLine("Foo({0})/ContextSwitch():1", taskId); nekara.ContextSwitch(); int lx1 = x; Console.WriteLine("Foo({0})/ContextSwitch():2", taskId); nekara.ContextSwitch(); int lx2 = x; Console.WriteLine("Foo({0})/Release()", taskId); if (taskId != 1) { lck.Release(); } nekara.Assert(lx1 == lx2, "Race!"); Console.WriteLine("Foo({0})/EndTask()", taskId); nekara.EndTask(taskId); }
public void Foo(int taskId) { this.nekara.Api.StartTask(taskId); bool temp = !(this.t2 && this.t3) && ((this.t2 && !this.t3) || (!this.t2 && this.t3)); if ((x == 1) && temp) { this.bugFound = true; } if (this.bugFound == true) { this.nekara.Api.EndTask(taskId); return; } Console.WriteLine("Foo({0})/Acquire()", taskId); lck.Acquire(); if (taskId == 2) { this.t2 = true; } else if (taskId == 3) { this.t3 = true; } x = taskId; Console.WriteLine("Foo({0})/ContextSwitch():0", taskId); this.nekara.Api.ContextSwitch(); Console.WriteLine("Foo({0})/ContextSwitch():1", taskId); this.nekara.Api.ContextSwitch(); int lx1 = x; Console.WriteLine("Foo({0})/ContextSwitch():2", taskId); this.nekara.Api.ContextSwitch(); int lx2 = x; Console.WriteLine("Foo({0})/Release()", taskId); if (taskId != 1) // lck.Release(); { lck.Release(); } else { if (!this.t2 || !this.t3) { // Deadlock this.bugFound = true; } } // nekara.Assert(lx1 == lx2, "Race!"); - Race will never happen Console.WriteLine("Foo({0})/EndTask()", taskId); this.nekara.Api.EndTask(taskId); }
static void Foo() { nekara.StartTask(1); Console.WriteLine("Foo/Acquire()"); lck.Acquire(); Console.WriteLine("Foo/ContextSwitch()"); nekara.ContextSwitch(); int lx1 = x; Console.WriteLine("Foo/ContextSwitch()"); nekara.ContextSwitch(); int lx2 = x; Console.WriteLine("Foo/Release()"); lck.Release(); nekara.Assert(lx1 == lx2, "Race!"); Console.WriteLine("Foo EndTask"); nekara.EndTask(1); }