From owner-freebsd-hackers Sun Jan 16 21:15: 3 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 E4D3415013 for ; Sun, 16 Jan 2000 21:15:00 -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 12A4VD-0000di-00; Sun, 16 Jan 2000 22:14:56 -0700 Message-ID: <3882A640.2A63B02A@softweyr.com> Date: Sun, 16 Jan 2000 22:18:56 -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: Michael Bacarella Cc: Alexander Litvin , hackers@FreeBSD.ORG Subject: Re: Preemptiveness of FreeBSD threads References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Michael Bacarella wrote: > > > 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! > > Hmmm, my prior response was pretty much bullshit. It doesn't work > for me with 'volatile' at all. > > [...] > > Putting a sched_yield(); in the loop body makes sure that they get their > fair share, so, other than guessing FreeBSD is at fault, I'm out of ideas. :) Yup, that does it, but it makes the program several orders of magnitude slower, too. Be careful about how much you use sched_yield, you're pushing the system into behavior that is outside its normal operating design. FreeBSD wasn't designed to re-run the scheduler after 2 or 3 instructions. -- "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