10

When I renice a multithreaded process in Ubuntu 10.04, then view the results in top, it seems that only the main thread actually gets reniced. All the other threads retain their old nice value. What's the easiest way to renice all threads in a process instead of just the main thread?

3 Answers 3

9
renice +/-n -g gid

Where gid is the process group id which you can find with ps -Aj

2

Inspired by zhihui's answer, what I actually used:

renice -n <niceness> -p `ps --no-heading -Lo tid <PID>`
1

The following command can set the nice value to +15 for all threads in process "procid":

ps --no-heading -Lj <procid> | awk '{system("renice +15 "$4)}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.