From owner-freebsd-hackers Wed Jan 6 19:37:06 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA24638 for freebsd-hackers-outgoing; Wed, 6 Jan 1999 19:37:06 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA24628 for ; Wed, 6 Jan 1999 19:37:04 -0800 (PST) (envelope-from tlambert@usr09.primenet.com) Received: (from daemon@localhost) by smtp01.primenet.com (8.8.8/8.8.8) id UAA07169; Wed, 6 Jan 1999 20:36:26 -0700 (MST) Received: from usr09.primenet.com(206.165.6.209) via SMTP by smtp01.primenet.com, id smtpd006958; Wed Jan 6 20:36:14 1999 Received: (from tlambert@localhost) by usr09.primenet.com (8.8.5/8.8.5) id UAA11431; Wed, 6 Jan 1999 20:35:52 -0700 (MST) From: Terry Lambert Message-Id: <199901070335.UAA11431@usr09.primenet.com> Subject: Re: pthreads question/problem... To: dot@dotat.at (Tony Finch) Date: Thu, 7 Jan 1999 03:35:52 +0000 (GMT) Cc: hackers@FreeBSD.ORG In-Reply-To: from "Tony Finch" at Jan 6, 99 01:21:07 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > >In fact we have a port of the linux threads to FreeBSD so we can do > >EXACTLY what they do, including the kernel support. It's being worked on > >as we speak. Some is already committed to -current. There is little > >argumant however that the ultimate is to schedule N threads over M > >processes where M is related to teh number of CPUs available. > > Sometimes you want M to be large relative to the number of CPUs > because you are using threading to improve userland IO concurrency. Finish the thought: "...and you don't want to use async I/O to improve I/O concurrency because, while doing so would be less overhead than using a bunch of threads, it doesn't accomplish your *real* goal." The *real* reasons you use M threads, where M > N, are: 1) You set M := N + 1 because you haven't implemented a cooperative scheduler, and you use the "+ 1" thread to spawn other threads each time you hit a blocking operation in the kernel because you are using threads as a poor substitute for asynchronous call contexts because some idiot on the POSIX committed thought that make a duplicate incomplete subset of the existing system calls to get async I/O was a fine idea. 2) You set M > N + 1, because you want to compete with the other processes on the system as M quantum units as work instead of as N quantum units of work, and you don't care how much context switch thrashing you generate while you are doing it because your process is so important compared to the other processes (that are doing the same damn thing to try and screw your process the same way) that you're willing to be evil instead of dealing with the "scheduler class" issue like a computer scientist. Which leads to: a) Hey! Why is 90% of my time spent in "system" instead of "user", and profiling shows that it's all in the scheduler and the pager? b) You write a scheduler class to give your X server a fixed percentage of the available quantum because you don't have working set limits on a per process or per vnode basis, and your stupid linker mmap's the object files, and without a working set limit to stop it, thrashes your entire X server out of core, and your naieve soloution is to give the X server enough of the CPU that it can thrash itself back in to give the appearance of "good interactive response" to the "move mouse, wiggle cursor" problem. You call the scheduler class "fixed(*)", which the underlying problem definitely isn't. * Any similarity to UnixWare(tm), Linux, or *BSD, running or stuck thrashing pages in and out of core for no good reason, is purely intentional. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message