In a linux VM, command "nice" allows the user to launch a process with a priority that is higher or lower than normal, so it uses more or less percent of cpu power. The user can also lower or raise the priority of a running process with tools like "htop".
But is it possible for the user to lower the priority of a specific thread within a running process?
The reason I'm asking, the adobe flash plugin for firefox makes the entire user interface of a linux VM unresponsive when the cpu runs at 100%. Seen the same happen when the priority of a cpu-intensive process is raised too much. So it is logical that flash runs some threads in too
high priority, and we don't want that.
Any tricks to slow down a firefox plugin (.so executable) like flash?
Firefox 3.6.x creates a separate process for running flash plugin - you can alter its priority automatically by e.g. running this script (save it to a file, and make it executable using 'chmod +x filename.sh' command):
#! /bin/bash while :; do renice 20 -p `ps ax | grep plugin-container | grep -v grep | awk '{print $1}'` &> /dev/null sleep 1 done
However this script won't address the core problem with your flash - the fact that it uses 100% of CPU time.
I'd suggest going to youtube, right clicking any video, choosing "Settings ..." and disabling/enabling "Hardware acceleration".
That's cool. Will require some testing.
There seem to be several processes associated with the flash plugin, seen this in htop, can also be seen if you type:
top -H -n 1 | grep plugin-cont
Can't find how the same can be done with "ps". Do you know?
Hm, probably you're right, we need to change all threads priority:
renice 20 -p `top -H -n 1 | grep plugin-cont | grep -v grep | awk '{print $2}'` &> /dev/null
Command "top" doesn't show them all, in htop if you press F5 it shows 4 of them when watching a youtube video. Whereas "top" shows 2 or 3.
So "ps" must be the right way to do it, as alluded in my previous post. But what parameters do you give to "ps" to make it show a tree view that includes all threads?