test_cleanup hangs with N:1 scheduling

Marijn Ros <[email protected]> 19 May 2002 14:16:12 +0200
Newsgroups gmane.linux.ngpt.user
Message-ID <[email protected]>
Hi all,

With MAXNATIVETHREADS=1 (default on uni-processors), the main thread
of test_cleanup never wakes from its sleep, as more then one other
thread is doing endless calculations. The calculating-threads do yield
a lot (through pthread_testcancel), but only to themselves.

Although this behaviour is probably allowed by the POSIX
specifications, nobody actually expects it to happen.

The workaround I use is to allow the eventmanager to run on every
schedule-point, instead of only when there are no or exactly one
threads ready to run.

The one-liner patch I made is attached for reference. But please
notice, I don't understand the scheduler and so also don't know what
the side-effects will be (except slower scheduling, of course).

Bye,
        Marijn


===File ~/NGPT/ngpt-1.9.0/pth_sched-N1.diff=================
--- ../ngpt-1.2.2/pth_sched.c	Mon Apr 29 13:04:37 2002
+++ pth_sched.c	Sun May 19 14:13:49 2002
@@ -631,7 +631,6 @@
             && pth_pqueue_elements(NQ) == 0 ) {
 	    pth_sched_eventmanager(&snapshot, descr, FALSE /* wait */);
         } else {
-	    if (rq_elements == 1)
 	    	pth_sched_eventmanager(&snapshot, descr, TRUE  /* poll */);
 	}
     }
============================================================