Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Dec 1999 10:44:19 +0100
From:      "Steffen Merkel" <d_f0rce@gmx.de>
To:        "Richard Seaman, Jr." <dick@tar.com>
Cc:        <freebsd-hackers@freebsd.org>
Subject:   Re: Kernel threads
Message-ID:  <001c01bf5118$1f4936a0$0201a8c0@blade>
References:  <005101bf508e$1ab48700$0201a8c0@blade> <Pine.SOL.4.05.9912270929080.24373-100000@luna.lyris.com> <19991227120931.H5975@tar.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello,

> 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.

Sorry, but I'm learning C for only some weeks now. Why does the main
thread complete if I insert a while(1); ? I thougt that this while statement
would get executed forever (until I press ^C).

> > 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.

How can I then tell FreeBSD that my threads shall be kernel threads?


Steffen




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?001c01bf5118$1f4936a0$0201a8c0>