Tests on powerpc-unknown-linux-gnu

Andrew Haley aph@cambridge.redhat.com
Thu Mar 21 05:22:00 GMT 2002


Andrew Haley writes:
 > Bryce McKinlay writes:
 > > Mark Wielaard wrote:
 > > 
 > > >=== libjava Summary ===
 > > >
 > > ># of expected passes 2039
 > > ># of unexpected failures 2
 > > ># of expected failures 18
 > > ># of untested testcases 14
 > > >
 > > >The two failures are from Thread_Interrupt which seems to just Abort.
 > > >
 > > 
 > > Odd. Thread_Interrupt works for me.
 > 
 > I get the same Thread_Interrupt failures. I'll have a look.
Got it: we don't wait for long enough on a fast machine for the
interrupting thread to start.
This patch fixes the problem.
Andrew.
2002年03月21日 Andrew Haley <aph@cambridge.redhat.com>
	* libjava.lang/Thread_Interrupt.java (Looper.calibrate): New.
	(yields): New.
Index: Thread_Interrupt.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.lang/Thread_Interrupt.java,v
retrieving revision 1.1
diff -u -r1.1 Thread_Interrupt.java
--- Thread_Interrupt.java	2000年03月23日 12:35:44	1.1
+++ Thread_Interrupt.java	2002年03月21日 13:19:47
@@ -44,12 +44,33 @@
 
 class Looper extends Thread
 {
+ // Return the number of Thread.yield()s we can do in 500ms.
+ static long calibrate ()
+ {
+ long i = 1;
+
+ for (int tries = 0; tries < 40; tries++)
+ {
+	long t = System.currentTimeMillis();
+	for (long n = 0; n < i; n++)
+	 Thread.yield();
+	long t_prime = System.currentTimeMillis();
+	if (t_prime - t > 500)
+	 return i;
+	i *= 2;
+ }
+ // We have no system clock. Give up.
+ throw new RuntimeException ("We have no system clock.");
+ }
+
+ static long yields = calibrate ();
+
 public void run()
 {
 System.out.println ("Busy waiting");
 
 int count = 0;
- for (int i=0; i < 1000000; i++)
+ for (long i=0; i < yields; i++)
 {
 Thread.yield();
 	count += 5;


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /