From owner-freebsd-chat Fri Jul 16 17:37:54 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 2232C14CF7 for ; Fri, 16 Jul 1999 17:37:48 -0700 (PDT) (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; Fri, 16 Jul 1999 17:36:15 -0700 From: "David Schwartz" To: "Terry Lambert" Cc: , Subject: RE: Known MMAP() race conditions ... ? Date: Fri, 16 Jul 1999 17:36:14 -0700 Message-ID: <000101becfec$605cd280$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: <199907170026.RAA19207@usr05.primenet.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > > FreeBSD's user space threads implementation uses call conversion > > > to wrap system calls. > > > > Some system calls. > > Which ones? What you are saying is tantatmount claiming that libc_r > is incomplete. Identify the problems that you are having, and they > will be fixed. > > Just saying "it's broke" is worse than useless. I was under the impression that disk I/O was still blocking in FreeBSD's libc_r. I was also under the impression that the resolver was blocking. If disk I/O really is non-blocking, I would expect the performance to suffer because thread context switches in a user-space threads implementation are generally more expensive than a kernel thread blocking on I/O. User-space threads are not inherently bad, they just have different tradeoffs than kernel threads. > Yes. The NFS code can return "EWOULDBLOCK", if the operation would > block. But does libc_r do this? As I see it, there are two answers, and both are at least somewhat bad: 1) Yes. Which means that a significant fraction of disk I/O will require extra user-space thread context switches. 2) No. Which means that slow I/O will stall all the threads. > > Umm, huh? Reading from an NFS server is buggy? Reading from a > slow disk is > > buggy? > > No. Both cases should result in an EWOULDBLOCK and a threads context > switch, pending the data being present to be read, since non-blocking > I/O is being substituted. Which means unneccesary context switches, when simply waiting would be better. The problem is, if you want to avoid the occasional long delay, you have to accept extra context switches all the time. Not necessarily the worst thing in the world, but it's a tradeoff. > > I see them all the time. 'gethostbyname' is a good example. > > Are you forcing the use of TCP for this? This results in a spin > loop. > > Please obtain and compile the libresolver from bind 8.x, which is > reentrant, and link it before you link libc_r. I am calling 'gethostbyname'. Is that wrong? Bind's license, unfortunately, prohibits me from linking to it. Once I wrote my own resolver library, this problem goes away. But not everyone can spend the time to do that to optimize for a platform. > > NFS reads are too. > > A slow server should be no problem. The read call, in the case > of non-blocking I/O, checks for the presence of a local backing > page, and if it is not present, schedules a fault-in of the page > (the real read), and returns "EWOULDBLOCK". > > If you are saying this does not work, then it is a bug that > needs to be addressed. I believe Matt Dillon is currently > hacking in the NFS code, and could address this in almost no > time, given his familiarity with the VM system. That's not what I'm saying. I'm saying it's a painful tradeoff. What you want is a thread to block if the I/O takes too long. You don't have that choice. > > Any problem can be fixed ten ways. The thing is, if code > > that runs fine everywhere else breaks on FreeBSD, you have to > > start suspecting that it's the OS. The point of this is not > > "FreeBSD's threads is bad", it's not that bad. It's just not up > > to some real world applications. And for those, another OS might > > be a better choice. > > If it's "not that bad", then it won't take 10 years to fix. Yes, I've been waiting for fixes in FreeBSD's threads implementation for more than a year now. The vast majority of them have taken place, and I'm fairly happy with the current state of FreeBSD's threads support. However, it is really not as good as the threads support on many other operating systems, including NT. If you need stellar threads support, FreeBSD is not the operating system you probably want to use. At the current rate of progress though, this could change in a few months. DS To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message