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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to