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
renice +/-n -g gid
Where gid
is the process group id which you can find with
ps -Aj
Inspired by zhihui's answer, what I actually used:
renice -n <niceness> -p `ps --no-heading -Lo tid <PID>`
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)}'