Pthread scheduling in FreeBSD 7
gregor at net.t-labs.tu-berlin.de
Tue Nov 27 04:06:50 PST 2007
-----BEGIN PGP SIGNED MESSAGE-----
I have a question concerning *pthread* scheduling with FreeBSD 7.
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
* 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?
Gregor Maier gregor at net.t-labs.tu-berlin.de
TU Berlin / Deutsche Telekom Labs gregor.maier at tu-berlin.de
Sekr. TEL 4, FG INET www.net.t-labs.tu-berlin.de
10587 Berlin, Germany
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the freebsd-stable