[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading TestM
From: |
Thong Nguyen <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading TestMonitor.cs,1.3,1.4 |
Date: |
Tue, 08 Jul 2003 08:47:24 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Threading
In directory subversions:/tmp/cvs-serv24106/System/Threading
Modified Files:
TestMonitor.cs
Log Message:
Added extreme thrash test
Index: TestMonitor.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Threading/TestMonitor.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** TestMonitor.cs 8 Jul 2003 04:59:08 -0000 1.3
--- TestMonitor.cs 8 Jul 2003 12:47:21 -0000 1.4
***************
*** 223,232 ****
thread1 = new Thread(new ThreadStart(Run1));
thread2 = new Thread(new ThreadStart(Run2));
!
thread1.Start();
thread2.Start();
- Console.Write("Thrashing will take 4 seconds ... ");
-
/* Testing shows 4 seconds is *usually* enough to cause
a failure if monitors aren't working */
--- 223,236 ----
thread1 = new Thread(new ThreadStart(Run1));
thread2 = new Thread(new ThreadStart(Run2));
!
! state = 0;
! failed = false;
! stop = false;
!
! Console.Write("Thrashing will take 4 seconds ... ");
!
thread1.Start();
thread2.Start();
/* Testing shows 4 seconds is *usually* enough to cause
a failure if monitors aren't working */
***************
*** 238,241 ****
--- 242,292 ----
thread1.Join();
thread2.Join();
+
+ AssertEquals("Monitor locking", failed, false);
+ }
+
+ public void TestMonitorExtremeMultiThreadedThrash()
+ {
+ Thread[] threads;
+
+ if (!TestThread.IsThreadingSupported)
+ {
+ return;
+ }
+
+ state = 0;
+ failed = false;
+ stop = false;
+
+ threads = new Thread[10];
+
+ Console.Write("Thrashing will take 4 seconds ... ");
+
+ for (int i = 0; i < 10; i++)
+ {
+ if (i % 2 == 0)
+ {
+ threads[i] = new Thread(new ThreadStart(Run1));
+ }
+ else
+ {
+ threads[i] = new Thread(new ThreadStart(Run2));
+ }
+
+ threads[i].Start();
+ }
+
+
+ /* Testing shows 4 seconds is *usually* enough to cause
+ a failure if monitors aren't working */
+
+ Thread.Sleep(4000);
+
+ stop = true;
+
+ for (int i = 0; i < 10; i++)
+ {
+ threads[i].Join();
+ }
AssertEquals("Monitor locking", failed, false);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading TestMonitor.cs,1.3,1.4,
Thong Nguyen <address@hidden> <=