From owner-freebsd-hackers Tue Dec 28 1:44: 6 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.erlangen.netsurf.de (erlangen.netsurf.de [194.163.170.1]) by hub.freebsd.org (Postfix) with ESMTP id 4B6F5152EE for ; Tue, 28 Dec 1999 01:44:03 -0800 (PST) (envelope-from d_f0rce@gmx.de) Received: from blade (user-er-u1.erlangen.netsurf.de [194.163.170.161]) by mail.erlangen.netsurf.de (8.9.3/8.9.3) with SMTP id KAA91922; Tue, 28 Dec 1999 10:43:52 +0100 (CET) Message-ID: <001c01bf5118$1f4936a0$0201a8c0@blade> From: "Steffen Merkel" To: "Richard Seaman, Jr." Cc: References: <005101bf508e$1ab48700$0201a8c0@blade> <19991227120931.H5975@tar.com> Subject: Re: Kernel threads Date: Tue, 28 Dec 1999 10:44:19 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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