From owner-freebsd-hackers Thu Oct 19 18:31:02 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id SAA08896 for hackers-outgoing; Thu, 19 Oct 1995 18:31:02 -0700 Received: from werple.net.au (0@werple.mira.net.au [203.9.190.18]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id SAA08891 for ; Thu, 19 Oct 1995 18:30:54 -0700 Received: from cimaxp1.UUCP (Ucimlogi@localhost) by werple.net.au (8.7/8.7) with UUCP id LAA08945 for hackers@freebsd.org; Fri, 20 Oct 1995 11:03:32 +1000 (EST) Message-Id: <199510200103.LAA08945@werple.net.au> X-Authentication-Warning: werple.net.au: Ucimlogi set sender to cimaxp1!jb using -f Received: by cimaxp1.cimlogic.com.au; (5.65/1.1.8.2/10Sep95-0953AM) id AA17525; Fri, 20 Oct 1995 11:05:30 +1000 From: John Birrell Subject: Re: NetBSD/FreeBSD (pthreads) To: julian@ref.tfs.com (Julian Elischer) Date: Fri, 20 Oct 1995 11:05:29 +1000 (EST) Cc: hackers@freebsd.org, jb@cimlogic.com.au In-Reply-To: <199510192246.PAA23918@ref.tfs.com> from "Julian Elischer" at Oct 19, 95 03:46:19 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-hackers@freebsd.org Precedence: bulk Julian, > > > I'm curious about why you *need* kernel threads. > > usually it's for several blocking IO streams.. The user space threads implementation fudges blocking IO and this works fine for us. > > > > > If you end up trying to use the MIT threads, watch out! We ended up completely > > retructuring the code to a more sane (IMHO) implementation. > this is the stuff you ended up using right? Yes, we ended up using our restructured version. We've got a customer deadline to meet with $$$ attached, so this was an easy decision to make. > have you forwarded your changes back? No. Instead I've started talking to a few NetBSD folks about making libc support pthreads directly. The MIT implementation has duplicated _many_ of the libc functions, including the assembly language stuff like setjmp. This makes supporting the system (pthreads + opsys) more difficult than it needs to be. So we changed libc to allow for threads. We build it twice, once with a preprocessor definition _THREAD_SAFE and once without it. For the threaded version, a few extra source files are compiled. We always link against libc, never libpthread.a and _then_ libc. The MIT implementation tries to sit on top of a system like FreeBSD/NetBSD. We believe that it should be part of it. Our implementation is now so different to the one from MIT that I doubt they'd be receptive to changes that affect their basic design. [Sorry if I have jumped to the wrong conclusion]. As an example of an area where our design differs, consider handing signals. MIT uses a global set of signal handler definitions. We do this on a thread-by-thread basis. A thread that is interrupted by a signal which it wants to catch, suspends while a signal-handler-thread runs. This thread can do what it believes is blocking IO and it can catch signals (which cause additional signal-handler-threads to run and so on). The scheduler allows threads that are not waiting on signal handler threads to compete against any signal-handler-threads. Our scheduler allows a context switch when the real signal handler function is about to return. Threads are context switched out by another thread doing blocking I/O or by a signal, the most common of which is SIGVTALRM. Another area where we differ from MIT, is in the use of mutexes internally within the threaded library. We believe that mutexes are things that the library provides, but that the low level implementation should not use them. This means that we have stripped the malloc mutex, the file descriptor mutexes, the key-specific mutex etc. We inhibit signals from interrupting the scheduler in zones of code that need to be protected. > > are you doing this under FreeBSD as well? We're a bit behind with FreeBSD. You guys move so quickly... 8-). We've ported all our non-threaded code to FreeBSD (2.0.5R). With the exception of the function in the kernel which locates SYSVSHM segments, there were no problems. (NetBSD fixed SYSVSHM a few months ago. 2.0.5R behaves as NetBSD did). We're currently writing widgets so that we don't rely on Motif. Then all we need is libc in FreeBSD to be ported to support pthreads and we have our factory process monitoring and control product ready to go under FreeBSD. Are you prepared to consider changing the FreeBSD libc to allow the _option_ of building a threaded version? Do you prefer keeping a separate libpthread like MIT builds? Are you using the MIT pthreads under FreeBSD? > > julian > -- John Birrell CIMlogic Pty Ltd jb@cimlogic.com.au 119 Cecil Street Ph +61 3 9690 9600 South Melbourne Vic 3205 Fax +61 3 9690 6650 Australia Mob +61 18 353 137