From owner-freebsd-chat Thu Dec 2 13:46:38 1999 Delivered-To: freebsd-chat@freebsd.org Received: from shell.webmaster.com (mail.webmaster.com [209.133.28.73]) by hub.freebsd.org (Postfix) with ESMTP id F3DDF14F82 for ; Thu, 2 Dec 1999 13:46:33 -0800 (PST) (envelope-from davids@webmaster.com) Received: from whenever ([209.133.29.2]) by shell.webmaster.com (Post.Office MTA v3.5.3 release 223 ID# 0-12345L500S10000V35) with SMTP id com; Thu, 2 Dec 1999 13:46:14 -0800 From: "David Schwartz" To: "Terry Lambert" Cc: Subject: RE: threads.... Date: Thu, 2 Dec 1999 13:46:14 -0800 Message-ID: <000101bf3d0e$a7e8c6b0$021d85d1@youwant.to> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0 In-reply-to: <199912022118.OAA28482@usr08.primenet.com> X-Mimeole: Produced By Microsoft MimeOLE V5.00.2919.6600 Importance: Normal Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > You're joking right? Or do you think that real-world server > applications > > don't mind if you freeze everything while the kernel services a > page fault > > or reads a file from a slow disk? I'm not sure you read what I wrote, since you didn't respond to it. > The question is why the application is threaded; there are a > number of reasons to thread an application: > > 1) In order to have seperate, similar (or identical) "tasks" > operating in parallel. In other words, in order to obtain > multiple program counters. > > NB: I believe this is th ICQ case This is the trivial case for threads. This can clearly be done in user-space (and, IMO, should be). > 2) To achieve some level of concurrency on a UP system by > interleaving rather than serializing I/O. > > NB: This can be accomplished using async I/O > > NB: This can be accomplished using non-blocking I/O, > if the systems I/O subsystem is built to take > the hint that it got and queue the read-ahead > before returning the "EWOULDBLOCK" to user space Tell me, how do you handle a page fault asynchronously? Who does the kernel return the 'EWOULDBLOCK' to? > 3) To achieve SMP scaling by giving the kernel scheduler > discrete object to apply the quanta from more than one > CPU, in order to get multiple CPUs into user space in > a single process. Actually, this can be essential in the UP case as well. You may have a high-priority subtask that needs to be scheduled a certain way and a lower-priority subtask the needs to be scheduled somewhat different. It can be nearly impossible to do this in a user-space scheduler. > Therefore, the only reason for kernel threads on FreeBSD, Linux, > or BSDI at this time is SMP scalability. As a means of SMP > scaling, this approach leaves a hell of a lot to be desired, > since it does not address the CPU affinity, thread group affinity, > or significantly increased context switch overhead issues. Actually, it's also needed for portability. There's an awful lot of code out there written for kernel threads. It's a very non-trivial task to make that use asynchronous I/O just for FreeBSD. So until FreeBSD gets real kernel threads, that code will continue to run pitifully on it. Also, making all your I/O non-blocking (even in the cases where it appears through static analysis that it's very unlikely to block) is very expensive computationally. You have to be ready to 'hold your place' everywhere. If the block is likely, it's worth it. But if the block is extremely rare, the cost of placeholding (just in case you block) will be enormous. The only sane way to resolve it will be to do most of your I/O synchronously, and you'll be left vulnerable to ambush on a surprise block, say due to a failing local disk drive. > Hope that answers your question; if it doesn't, please see the > current discussion on -arch in the mailing list archives to see > what a real low overhead, SMP scalable, threading system has to > look like. In the interests of keeping the signal to noise ration on -arch as high as possible, I don't follow that newsgroup. DS To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message