From owner-freebsd-hackers Sun Jan 16 20:41:13 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.nyct.net (bsd4.nyct.net [204.141.86.6]) by hub.freebsd.org (Postfix) with ESMTP id A6D2E14E35 for ; Sun, 16 Jan 2000 20:41:10 -0800 (PST) (envelope-from mbac@nyct.net) Received: from bsd1.nyct.net (mbac@bsd1.nyct.net [204.141.86.3]) by mail.nyct.net (8.8.8/8.8.7) with ESMTP id XAA18205; Sun, 16 Jan 2000 23:41:09 -0500 (EST) (envelope-from mbac@nyct.net) Received: from localhost (mbac@localhost) by bsd1.nyct.net (8.8.8/8.9.3) with ESMTP id XAA01231; Sun, 16 Jan 2000 23:41:09 -0500 (EST) (envelope-from mbac@nyct.net) X-Authentication-Warning: bsd1.nyct.net: mbac owned process doing -bs Date: Sun, 16 Jan 2000 23:41:09 -0500 (EST) From: Michael Bacarella To: Alexander Litvin Cc: hackers@FreeBSD.ORG Subject: Re: Preemptiveness of FreeBSD threads In-Reply-To: <20000116225044.C601@unknown.nowhere.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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. If I put: printf ("running %d\n", pthread_self()); right before the counter loop, I only get one thread telling me about itself. Seems like a scheduler problem. Perhaps it is treating all threads as a logical unit and assigning them a global priority, and selecting the same thread to suck up all of it's time, each time. A "successful" run probably happens on busier systems where other factors mess with scheduling -- but I haven't verified this. 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. :) -MB To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message