[fpc-devel] Linux thread priority mess (and possible implementation)
Jonas Maebe
jonas.maebe at elis.ugent.be
Thu Jun 24 16:25:19 CEST 2010
On 24 Jun 2010, at 15:05, Graeme Geldenhuys wrote:
> Also does multiple schedulers apply to other non-Linux platforms too?
> eg: OSX, FreeBSD, NetBSD, Haiku, etc. Because currently any unix-type
> platform doesn't have Thread Priority support in FPC.
The POSIX pthread_setschedparam() api is not really appropriate in
this case. It's mainly geared at real-time threads, which is why POSIX
only define the behaviour of SCHED_RR and SCHED_FIFO parameters (both
of which are real-time schedulers in this context).
For SCHED_OTHER, the OS can do whatever it wants (including treating
it as another real-time scheduler class, or just as an alias for
SCHED_RR or SCHED_FIFO), and there is no guarantee that the
sched_priority field of the schedparam srtucture is used in that case
(the parameters are completely implementation-defined). Both http://opengroup.org/onlinepubs/007908775/xsh/pthread_setschedparam.html
and the Linux man page for pthread_setschedparam() mention that.
I'm not aware of any portable Unix API to set the priority of threads
scheduled by the default scheduler (unless that happens to be a
SCHED_FIFO or SCHED_RR real-time scheduler, which will only be the
case on real-time systems). I'm not even sure about what the low level
APIs are on particular Unix platforms such as Linux and Mac OS X.
Jonas
More information about the fpc-devel
mailing list