From owner-freebsd-stable@FreeBSD.ORG Tue Nov 27 12:06:50 2007 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99F8216A477 for ; Tue, 27 Nov 2007 12:06:50 +0000 (UTC) (envelope-from gregor@net.t-labs.tu-berlin.de) Received: from mail.net.t-labs.tu-berlin.de (mail.net.t-labs.tu-berlin.de [130.149.220.252]) by mx1.freebsd.org (Postfix) with ESMTP id 2F3F013C448 for ; Tue, 27 Nov 2007 12:06:50 +0000 (UTC) (envelope-from gregor@net.t-labs.tu-berlin.de) Received: from [130.149.220.26] (pigeon.net.t-labs.tu-berlin.de [130.149.220.26]) by mail.net.t-labs.tu-berlin.de (Postfix) with ESMTP id 777A7705D832 for ; Tue, 27 Nov 2007 12:48:53 +0100 (CET) Message-ID: <474C0425.2060906@net.t-labs.tu-berlin.de> Date: Tue, 27 Nov 2007 12:48:53 +0100 From: Gregor Maier Organization: TU Berlin, FG INET User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: freebsd-stable@freebsd.org X-Enigmail-Version: 0.95.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Pthread scheduling in FreeBSD 7 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2007 12:06:50 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I have a question concerning *pthread* scheduling with FreeBSD 7. My goal: I have a multi-threaded application, in which I have a thread that should get higher priority than the other threads. Realtime-Priority for this thread would be nice but is not necessary. My approach so far (which worked for FreeBSD 6.2): Use the libpthread implementation, use pthread_attr_setschedparam() to increase the priority (scope is PTHREAD_SCOPE_SYSTEM, policy is SCHED_RR). For the libpthread implemenation that worked fine and did just what I expected. I also tried it using libthr, but libthr didn't care about the priority. My prolbem in FreeBSD 7: The libpthread implementation seems to have gone and libthr is the default. However libthr still ignores the pthread scheduling parameters. (FreeBSD 7 has a different default priority and policy for libthr than FreeBSD 6 however). I also saw, that libkse is now available as a new M:N pthread implementation, so I tried using that. But libkse is significantly slower than libthr and libkse does not always schedule to all CPUs. As far as I can tell libkse only schedules to all CPUs if the load is small when the threads are created. I have never seen this behaviour with libpthread from FreeBSD 6. And libkse is quite unpredictable: I used a test program with 10 threads (with equal priority) and recorded the wall-runtime of each of them. The runtime of them differs by a factor of up to 5(!). I have to mention however, that I used different machines. The one running FreeBSD 6 is a dual-cpu AMD Athlon with 32bit OS, while the one running FreeBSD 7 is a dual-core Intel running a 64bit OS. In FreeBSD 6 I used SCHED_4BSD in the kernel, while I used SCHED_ULE in FreeBSD 7. My questions: * Can anyone shed some light on this issue? * How can I tune thread scheduling in FreeBSD 7? What happened to the libpthread implementation from FreeBSD 6? * What triggers the whether libkse schedules to only one or to all CPUs? Is this tuneable? * Do rtprio() and/or nice() work for single threads? * Any other ideas how I can assign a higher priority to a thread. Maybe even realtime priority? TIA Gregor - -- Gregor Maier gregor@net.t-labs.tu-berlin.de TU Berlin / Deutsche Telekom Labs gregor.maier@tu-berlin.de Sekr. TEL 4, FG INET www.net.t-labs.tu-berlin.de Ernst-Reuter-Platz 7 10587 Berlin, Germany -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHTAQldGiwgbikMYMRAie+AKCVY2CxJEmmnPer2OhF6WavK8seZwCfYlVQ a49Oq0EUHJq/FnSfcb+0p5M= =xl8X -----END PGP SIGNATURE-----