From owner-freebsd-hackers Sun Jan 16 20:39:21 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from FreeBSD.ORG (hibou.obs-besancon.fr [193.52.184.7]) by hub.freebsd.org (Postfix) with ESMTP id 3854F14C1A for ; Sun, 16 Jan 2000 20:39:15 -0800 (PST) (envelope-from jmz@FreeBSD.ORG) Received: (from jmz@localhost) by qix.jmz.org (8.9.3/8.9.3) id FAA65391; Mon, 17 Jan 2000 05:38:48 +0100 (MET) (envelope-from jmz@FreeBSD.ORG) Date: Mon, 17 Jan 2000 05:38:48 +0100 (MET) Message-Id: <200001170438.FAA65391@qix.jmz.org> From: Jean-Marc Zucconi To: eischen@vigrid.com Cc: archer@lucky.net, hackers@FreeBSD.ORG In-reply-to: <200001170423.XAA10093@pcnet1.pcnet.com> (message from Daniel Eischen on Sun, 16 Jan 2000 23:23:43 -0500 (EST)) Subject: Re: Preemptiveness of FreeBSD threads X-Mailer: Emacs References: <200001170423.XAA10093@pcnet1.pcnet.com> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I also have this problem it seems: $ cc a.c -pthread $ a.out ^C Thread 0x00: 0 Thread 0x01: 0 Thread 0x02: 0 Thread 0x03: 0 Thread 0x04: 0 Thread 0x05: 0 Thread 0x06: 0 Thread 0x07: 0 Thread 0x08: 0 Thread 0x09: 0 Thread 0x0a: 162033094 Excepted that the phases of the moon do not play - It's always in Thread 0x0a :-} FreeBSD 4.0-CURRENT #5: Wed Dec 22 05:00:15 MET 1999 (SMP, not running NTP) Jean-Marc >>>>> Daniel Eischen writes: > Alexander Litvin wrote:> First, I must say that this all concernes quite current >> CURRENT (Jan 9 or so). I don't know if the same holds for >> older versions. >> >> I'm kind of puzzled. >> >> I've a simple sample program (see at the bottom). It creates 10 >> threads with start function start_my_thread(), and then runs the >> same function in main(). So, we have 11 threads doing the same job. >> >> Function start_my_thread() just increments indefinitely counters >> (each thread has its own counter). >> >> Program, when killed with SIGINT, prints all counters and exits. >> >> Now, as I understand, userspace threads in FreeBSD are preemptive. >> So, though my 11 threads are all computational and do not do >> any syscalls, sleeps, sched_yield, whatever -- newertheless, >> the program should not be stuck in one thread. And it seems to >> be sometimes true. But only sometimes! >> >> Depending on the phase of the moon (it seems) sometimes my >> program gives (after ^C): >> >> ^C >> Thread 0x00: 0 >> Thread 0x01: 0 >> Thread 0x02: 0 >> Thread 0x03: 0 >> Thread 0x04: 0 >> Thread 0x05: 0 >> Thread 0x06: 0 >> Thread 0x07: 0 >> Thread 0x08: 0 >> Thread 0x09: 0 >> Thread 0x0a: 488133092 > Hmm, I can't get this to occur with your test program. I've tried > it several times and the threads seem to be scheduled properly. > If you figure out how to repeat this without relying on phases of > the moon, I'd be interested in hearing how. -- Jean-Marc Zucconi PGP Key: finger jmz@FreeBSD.ORG To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message