I believe that Pth 1.4.1 is not correctly executing pthread_exit(). Consider this simple test:
#include "pthread.h" #include <stdio.h> void* start(void* s) { fprintf(stderr, "in start() for thread %x\n", pthread_self()); pthread_exit(0); } int main() { pthread_t t1; pthread_t t2; fprintf(stderr, "start main\n"); pthread_create(&t1, NULL, start, NULL); pthread_create(&t2, NULL, start, NULL); fprintf(stderr, "leave main\n"); pthread_exit(0); } If the main thread reaches its pthread_exit() call before the two started threads have terminated, it should wait there until those two threads do terminate, then it should exit. See POSIX 9945-1:1996, section 16.2.5.2, lines 249 - 251 ("The process shall exit with an exit status of 0 after the last thread has been terminated.") Thus, the expected output should be something like: start main leave main in start() for thread 2 in start() for thread 3 and it is, when using the system-provided UnixWare, Solaris, and Linux threads libraries. However Pth 1.4.1 produces: start main leave main in start() for thread 805adb0 in start() for thread 806b078 **Pth** SCHEDULER INTERNAL ERROR: no more thread(s) available to schedule!?!? Abort(coredump) The culprit is the function pth_exit_cb(), which, in effect, won't let pthread_exit() finish if there are any threads on the "dead queue", which is where non-detached terminated threads are put. The above test case will work correctly with Pth if the threads are created detached. But there's nothing in the POSIX standard that says that detached threads are treated differently in terms of pthread_exit() waiting until all threads are terminated. Thus Pth is in error. The fix for this is the following: --- pth_lib.c..orig Sun Jan 27 06:03:40 2002 +++ pth_lib.c.fixed Tue Oct 15 11:00:04 2002 @@ -357,7 +357,6 @@ rc += pth_pqueue_elements(&pth_RQ); rc += pth_pqueue_elements(&pth_WQ); rc += pth_pqueue_elements(&pth_SQ); - rc += pth_pqueue_elements(&pth_DQ); if (rc == 1 /* just our main thread */) return TRUE; else Jonathan Schilling SCO/Caldera [EMAIL PROTECTED] ______________________________________________________________________ GNU Portable Threads (Pth) http://www.gnu.org/software/pth/ User Support Mailing List [EMAIL PROTECTED] Automated List Manager (Majordomo) [EMAIL PROTECTED]