2

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)?

4

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:

3

You are looking for: Auto Nice Daemon

The auto nice daemon activates itself in certain intervals and renices jobs according to their priority and CPU usage. Jobs owned by root are left alone. Jobs are never increased in their priority.
The renice intervals can be adjusted as well as the default nice level and the activation intervals. A priority database stores user/group/job tuples along with their renice values for three CPU usage time ranges. Negative nice levels are interpreted as signals to be sent to a process, triggered by CPU usage; this way, Netscapes going berserk can be killed automatically. The strategy for searching the priority database can be configured. AND also provides network-wide configuration files with host-specific sections, as well as wildcard/regexp support for commands in the priority database. Homepage: http://and.sourceforge.net/

You can easy install it on your Ubuntu:

# aptitude install and

And modify config file:

# vi /etc/and.priorities

You say:

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

It depend on what kind of GUI you are prefer. Get the name of your file manager and add it to config "/etc/and.priorities".

Unfortunately, Auto Nice Daemon can change prio in range -20 : 19.

It is the same as "man nice" give:

Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process).

To get -99 and rt(real-time) you should read next two mans:

# man chrt

# man ionice

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.