Ubuntu – How to increase the priority for a task permanently in linux machine

niceprocessprocess-priority

How to increase the priority for a task in linux machine?

What I've Done So Far: After small research i found that we can increase the priority to a task using NICE command and if we want to increase the priority for an existing task, then we can also use RENICE command

But my problem:

  1. In some tutorials its mentioned that, NICE values vary from 0 to 99, But in some tutorials states that NICE values vary from -20 to 19. Which one is correct?

  2. How to increase the NICE value for an GUI task? If we are doing copy using terminal then I can increase its priority using NICE command But How to increase the priority of a task done using GUI(for ex: copying files from USB to System through GUI)

  3. Is that possible to set the priority of a task for the life time? I want to set highest priority for "COPYING FILES IN SYSTEM(using GUI) permanently

Is there anyone who can help me to set the highest priority for a task(task done through GUI)?

Best Answer

I think you should ask in Unix & Linux but in any case, the ones that say that NICE values for CPU in Linux vary from 0 to 99 are just for Real Time OS. The nice values are between -20 to 20, being -20 the higher priority, in normal (the one that most of users uses) *NIX kernels for CPU. Which is for most cases.

Also, the file copying wouldn't need actually that much CPU (depending the filesystems) but the I/O priority. From kernel 2.6.26 the ionice values are determined by the CPU nice values using the following formulae:

io_priority = (cpu_nice + 20) / 5

Also, all process (unless modified source code) starts with "Best effort" priority class which uses the formulae above. But, in any case, you probably don't need to set this as default.

A way to set the I/O priority to start a process is doing:

ionice -c2 -n6 SOME_COMMAND

Process that would like to set/get their own I/O scheduling class and priority should use the ioprio_set and ioprio_get functions.

Also a nice warning from Linux Poison:

Read the description for realtime carefully. Realtime IO nice processes will starve the system completely until they are done using the disk. You can easily make your system non responsive for long periods of time.

Also, IO niceness only has effect if you are using the CFQ io scheduler . If you have an elevator= (as, deadline,noop) line in your menu.lst, IO niceness will have no effect.

Sources:

Related Question