BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

I know that the pthreads API doesn't provide for adjusting the scheduler priorities of individual threads, but is there any mechanism for doing so under linux/unix?

For example, threads often show up in the process table (top/ps) as individual process-like entities, and it is possible to nice individual processes.

So, can nice be applied to individual threads of a process or would it affect all the threads? Or just be rejected for any thread other than the first?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re: Thread priorities under *nix.
by borisz (Canon) on Oct 18, 2005 at 07:28 UTC
    Yes, you can use nice, renice or pthread_setschedparam.
    Boris