From owner-freebsd-hackers Sun Jan 16 21: 4:59 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.xmission.com (mail.xmission.com [198.60.22.22]) by hub.freebsd.org (Postfix) with ESMTP id A9FA21509D for ; Sun, 16 Jan 2000 21:04:56 -0800 (PST) (envelope-from wes@softweyr.com) Received: from [204.68.178.39] (helo=softweyr.com ident=wes) by mail.xmission.com with esmtp (Exim 3.03 #3) id 12A4LV-0006n1-00; Sun, 16 Jan 2000 22:04:53 -0700 Message-ID: <3882A3E5.2ABD9EBF@softweyr.com> Date: Sun, 16 Jan 2000 22:08:53 -0700 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 3.3-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Daniel Eischen Cc: archer@lucky.net, hackers@FreeBSD.ORG Subject: Re: Preemptiveness of FreeBSD threads References: <200001170423.XAA10093@pcnet1.pcnet.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Daniel Eischen wrote: > > 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. It does it every time for me, on 3.3-RELEASE. On 3.4-STABLE as of Dec 20, it never does it (over a very small sample period). The machines are located about 25 miles apart; the phase of the moon should be significantly the same for both. ;^) -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message