Preventing CPU/IO Intensive Programs Blocking Linux Gui

What for?

The fact that the linux kernel does NOT come with a GUI and the GUIs used are third party components, their default priority levels (or nice level, which is user-space name for priority.) are the same as any other user space programs. This may cause the GUI to freeze when performing CPU/IO intensive jobs since they all run at the same priority level.

What’s nice value/priority?

To prevent that, we need to change the nice level, where the priority of a process equals NICE_VALUE+20. That’s said, higher priority level, same as higher nice level, creates a less prior job.

Usually run a program with nice -n $NI_VALUE $COMMAND starts a program with a given nice value. renice -n NI_VALUE $PID changes the priority level of a process with the given pid. (multiple pid could be given to change them all)

Sub-processes owns the same nice level with their parents.

What about IO?

The above works for CPU priority only. For IO control, the default priority will be cpu_priority / 5 and one can always change that using ionice.

To make them automatic

I recommend putting the pivotal GUI components into startup script or crontab -e(cron needed to be installed) like this:

#"sudo crontab -e" to input
* * * * * renice -n -4 -p $(pidof vivaldi-bin)
* * * * * renice -n -8 -p $(pidof nautilus)
* * * * * renice -n -8 -p $(pidof Xorg)
* * * * * renice -n -8 -p $(pidof compiz)

2017/11/19