Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Dec 1999 12:09:31 -0600
From:      "Richard Seaman, Jr." <dick@tar.com>
To:        Kip Macy <kip@lyris.com>
Cc:        Steffen Merkel <d_f0rce@gmx.de>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Kernel threads
Message-ID:  <19991227120931.H5975@tar.com>
In-Reply-To: <Pine.SOL.4.05.9912270929080.24373-100000@luna.lyris.com>; from kip@lyris.com on Mon, Dec 27, 1999 at 09:34:49AM -0800
References:  <005101bf508e$1ab48700$0201a8c0@blade> <Pine.SOL.4.05.9912270929080.24373-100000@luna.lyris.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991227120931.H5975>