Ubuntu – Do all apps start with a normal priority on the system monitor

processprocess-prioritypulseaudio

I noticed that on my system monitor, one of my processes, titled pulseaudio, had a very high priority, while all of my other running apps had a normal priority. I don't recall ever changing it, so it must have been its default priority, right? Are there any other apps like this?

Best Answer

Technically, yes. In Linux — Ubuntu's kernel — all programs start with a priority or "niceness" value of 0. They may, while executing, request a higher or lower priority by making the system call nice(int niceness) from unistd.h.

Normally, programs the user runs only have the permission to lower their priority to positive niceness. This is useful for non-critical janitorial tasks your computer performs from time to time.

However, Ubuntu also uses a framework called AppArmor, which grants specific user programs administrative ("root") level rights. Ubuntu's AppArmor is configured to allow certain important programs to request a high priority (negative niceness), most notably PulseAudio. This prevents breaks in playing audio while your system is under heavy load.

In summary, yes all applications start with a normal priority. However, in practice, many applications request a different priority immediately after launching.

And as a little geeky addendum

You can start (or to be technically accurate, fork) your own programs with low/high priority in a commandline like this:

nice -n 10 my_app                 # this application is low priority, very nice
sudo nice -n -10 my_other_app     # this application is high priority, very mean

No guarantees they'll keep it, of course. ;)