[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nptl] Re: Patch for SCHED_RR test with LinuxThreads



> I tried on a SuSE v9.0 box:
> 
> SuSE Linux 9.0 (i586)
> Kernel 2.4.21-243-smp4G / i686
> 2 x Pentium III (Coppermine)
> 
> test passed up to 30 threads...
> 
> Then I tried 128 threads at prio 1. 
> It hung (and we had to hard reboot the computer).
> 
> Apparently, threads didn't even got created... 
> And it looks like - modulo BUG from me with the timeout - 
> that it hung in pthread_create() ? 

Got the same issue on NPTL.
The attached patch will help prevent the computer hard-reboot.

(to apply on the original sample)


-------------------------------
Sebastien DECUGIS
NPTL Test & Trace Project
http://nptl.bullopensource.org/

"You may fail if you try.
You -will- fail if you don't."

--- test_schedrr.c	2004-09-22 17:04:17.000000000 +0200
+++ test_schedrr.new.c	2004-09-22 17:01:24.550684640 +0200
@@ -93,6 +93,7 @@
 sigset_t              alarm_sigmask; 
 
 int nthreads;
+int nth_real;
 int prio;
 
 
@@ -200,6 +201,11 @@
     (void) sigwait (&alarm_sigmask, &sig_caught);
     if ( sig_caught == SIGALRM) {
       alarm_raised=1;
+	if (nth_real < nthreads)
+	{
+		printf("Timeout during threads creation\n");
+		exit(2);
+	}
     }
   }
   return NULL; // keep compiler happy 
@@ -268,16 +274,16 @@
 	  nthreads,
 	  prio
 	  );
-  for (i=0; i<nthreads && !alarm_raised; i++) {
-    info[i].started = 0;
-    info[i].stop    = 0;
-    info[i].counter = 0;
-    status = spawn_thread (&thrid[i], SCHED_RR, prio, cpu_thread, &info[i]);
+  for (nth_real=0; nth_real<nthreads && !alarm_raised; nth_real++) {
+    info[nth_real].started = 0;
+    info[nth_real].stop    = 0;
+    info[nth_real].counter = 0;
+    status = spawn_thread (&thrid[nth_real], SCHED_RR, prio, cpu_thread, &info[nth_real]);
     assert (status==0);
   }
   if ( alarm_raised ) {
     printf ("Started %d / %d threads only\n",
-	    i, nthreads
+	    nth_real, nthreads
 	    );
     dump_thread_info (info, nthreads);
     exit (1);
@@ -328,7 +334,7 @@
    * process main args
    */
   assert (argc!=2);
-  nthreads = atoi(argv[1]);
+  nthreads = nth_real = atoi(argv[1]);
   prio     = atoi(argv[2]);
   assert (1 <= nthreads && nthreads <= NR_MAX_THREADS );
   maxprio = sched_get_priority_max (SCHED_RR);