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?

dsimcha
  • 661
  • 1
  • 6
  • 12

3 Answers3

9
renice +/-n -g gid

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

7ochem
  • 280
  • 1
  • 3
  • 12
Red Tux
  • 2,074
  • 13
  • 14
2

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

renice -n <niceness> -p `ps --no-heading -Lo tid <PID>`
lvella
  • 284
  • 2
  • 13
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)}'
slm
  • 7,355
  • 16
  • 54
  • 72
zhihui
  • 11
  • 1