Пример #1
0
 public void Task2Petersen()
 {
     while (true)
     {
         Petersen.EnterRegion(1);
         //Console.WriteLine("#2 enter in critical section");
         if (countBeeps > count)
         {
             SystemSounds.Beep.Play();
             count++;
         }
         Thread.Sleep(500);
         //Console.WriteLine("#2 leave from critical section");
         Petersen.LeaveRegion(1);
     }
 }
Пример #2
0
 public void Task1Petersen()
 {
     while (true)
     {
         Petersen.EnterRegion(0);
         //Console.WriteLine("#1 enter in critical section");
         if (countBeeps > count)
         {
             Console.Beep();
             count++;
         }
         Thread.Sleep(500);
         //Console.WriteLine("#1 leave from critical section");
         Petersen.LeaveRegion(0);
     }
 }