From owner-freebsd-hackers Mon Dec 27 10:11:10 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from test.tar.com (test.tar.com [204.95.187.4]) by hub.freebsd.org (Postfix) with ESMTP id 5638714E83 for ; Mon, 27 Dec 1999 10:11:01 -0800 (PST) (envelope-from dick@test.tar.com) Received: (from dick@localhost) by test.tar.com (8.9.3/8.9.3) id MAA75089; Mon, 27 Dec 1999 12:09:31 -0600 (CST) (envelope-from dick) Date: Mon, 27 Dec 1999 12:09:31 -0600 From: "Richard Seaman, Jr." To: Kip Macy Cc: Steffen Merkel , freebsd-hackers@FreeBSD.ORG Subject: Re: Kernel threads Message-ID: <19991227120931.H5975@tar.com> References: <005101bf508e$1ab48700$0201a8c0@blade> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from kip@lyris.com on Mon, Dec 27, 1999 at 09:34:49AM -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Dec 27, 1999 at 09:34:49AM -0800, Kip Macy wrote: > The words "POSIX threads" only describes the API. It says nothing about > the implementation. On FreeBSD they are non-preemptive user level threads > (your main was never yielding so the thread you launched did not get any > time). Actually, FreeBSD user threads *are* pre-emptive. The problem is that a successful return from pthread_create guarantees that a thread is created, but not that it is started. The main thread exits before the second thread starts. Inserting a sleep allows the second thread to run. With just a while() the main thread completes before the second thread gets its time slice. As noted in a previous message, pthread_join() is intended for this kind of synchronization. > On Linux they are processes sharing the same virtual memory space, > and are referred to as kernel threads. For compute bound activities you > want kernel threads to spread the computation over multiple processors. Yes. As long as you have multiple processors. > For I/O bound activities you want user level threads so you can minimize > the context switch overhead. FreeBSD user threads have fairly high context switch overhead, especially when there are open fds that get polled on each context switch. Kernel threads are actually faster in many circumstances. The discussion in the -arch mailing list involves ideas which would make user threads much more efficient. -- Richard Seaman, Jr. email: dick@tar.com 5182 N. Maple Lane phone: 262-367-5450 Chenequa WI 53058 fax: 262-367-5852 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message