Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Nov 2007 12:48:53 +0100
From:      Gregor Maier <gregor@net.t-labs.tu-berlin.de>
To:        freebsd-stable@freebsd.org
Subject:   Pthread scheduling in FreeBSD 7
Message-ID:  <474C0425.2060906@net.t-labs.tu-berlin.de>

next in thread | raw e-mail | index | archive | help
-----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-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?474C0425.2060906>