From owner-freebsd-threads@FreeBSD.ORG Thu Jun 26 10:32:31 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 27A1537B401 for ; Thu, 26 Jun 2003 10:32:31 -0700 (PDT) Received: from titan.exolab.org (smtp.intalio.com [65.222.219.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B63643F85 for ; Thu, 26 Jun 2003 10:32:30 -0700 (PDT) (envelope-from boisvert@intalio.com) Received: from intalio.com (fwin.intalio.com [65.222.219.17]) by titan.exolab.org (8.11.1/8.11.1) with ESMTP id h5QHWTE20661 for ; Thu, 26 Jun 2003 10:32:29 -0700 Message-ID: <3EFB2E12.3080504@intalio.com> Date: Thu, 26 Jun 2003 10:32:02 -0700 From: Alex Boisvert User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-threads@freebsd.org Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: libkse / libthr bugs? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jun 2003 17:32:31 -0000 Hi, I written a small test case (see source below), which I've run against both libkse and libthr. I'm using -CURRENT as of last Tuesday and running on a Dual Athlon MP 1.2 GHz (Tyan Thunder K7 motherboard). With libkse, the program runs most of the time (say, about 9 times out of 10) but sometimes hang and, interestingly, prints an "F" character to the console -- but that "F" character is never printed by the application itself! (see source) Here are two examples of when it hangs: bipolar:boisvert:~/prog/pthread:48 gcc -g -lkse -o foo2 foo2.c bipolar:boisvert:~/prog/pthread:49 ./foo2 1000 Using 1000 threads (parameter) bar 0 bar 1 bar 2 Fbar 3 ^C bipolar:boisvert:~/prog/pthread:50 (Notice the "F" on the last line, before I had to use CTRL-C to terminate the application). Also, sometimes I get: bipolar:boisvert:~/prog/pthread:65 ./foo2 1000 Using 1000 threads (parameter) F ^C bipolar:boisvert:~/prog/pthread:66 I also tried the same test case with libthr and got a different behavior: bipolar:boisvert:~/prog/pthread:141 gcc -g -lthr -o foo2 foo2.c bipolar:boisvert:~/prog/pthread:142 ./foo2 1000 Using 1000 threads (parameter) bar 0 foo2: Unknown error: 0 bipolar:boisvert:~/prog/pthread:143 In this case, the behavior is more easily reproductible. So, maybe you can help me figure out if my test case is somehow invalid or these are genuine problems within the threading libraries... cheers, alex ----------- foo2.c #include #include #include void *foo(void *); typedef struct { int number; } arg_t; /** * Simple test case for the thread system. Start "n" threads, * and join them afterwards. */ int main( int argc, char** argv) { pthread_t* threads; arg_t* args; void* ret; int n; int i; if ( argc > 1 ) { n = strtoimax( argv[1], NULL, 10 ); printf( "Using %d threads (parameter)\n", n ); } else { n = 5; printf( "Using %d threads (default)\n", n ); } // initialize random number generator srandomdev(); threads = (pthread_t*) malloc( sizeof(pthread_t) * n ); args = (arg_t*) malloc( sizeof(arg_t) * n ); // start n threads for ( i=0; i