It is possible to change the way the kernel schedules a process so that the process gets more or less CPU time than other processes. The kernel runs each process according to its scheduling priority , which is a number between -20 and 19, with -20 being the foremost priority (yes, this can be confusing).
The ps -l command lists the current priority of a process, but it's a little easier to see how it works with the top command, as shown here:
Tasks: 79 total, 1 running, 77 sleeping, 0 stopped, 1 zombie Cpu(s): 9.4% us, 1.0% sy, 0.4% ni, 88.4% id, 0.6% wa, 0.0% hi, 0.1% si Mem: 320364k total, 301420k used, 18944k free, 17320k buffers Swap: 514072k total, 13260k used, 500812k free, 68260k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 23066 bri 16 0 1868 896 1732 R 5.6 0.3 0:00.06 top 10382 bri 15 0 93288 74m 28m S 1.9 23.7 200:04.75 MozillaFirebird 1 root 16 0 1348 480 1316 S 0.0 0.1 0:04.28 init 2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0 3 root 5 -10 0 0 0 S 0.0 0.0 0:06.36 events/0 4 root 5 -10 0 0 0 S 0.0 0.0 0:08.89 kblockd/0 5 root 15 0 0 0 0 S 0.0 0.0 0:00.02 khubd 6 root 25 0 0 0 0 S 0.0 0.0 0:00.00 pdflush 7 root 15 0 0 0 0 S 0.0 0.0 1:29.48 pdflush 8 root 15 0 0 0 0 S 0.0 0.0 1:01.23 kswapd0 9 root 10 -10 0 0 0 S 0.0 0.0 0:00.00 aio/0 10 root 19 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0 11 root 15 0 0 0 0 S 0.0 0.0 0:00.00 kseriod 127 root 16 0 1412 572 1360 S 0.0 0.2 0:03.24 syslogd 129 root 16 0 1344 464 1312 S 0.0 0.1 0:00.02 klogd 134 daemon 19 0 1436 404 1388 S 0.0 0.1 0:00.00 portmap 136 root 16 0 1380 516 1352 S 0.0 0.2 0:00.03 inetd
In the top output, the PR column lists the kernel's current schedule priority for the process. The higher the number, the less likely the kernel is to schedule the process if others need CPU time. The schedule priority changes frequently during program execution according to the amount of CPU time that the process consumes.
The schedule priority alone does not determine the kernel's decision to give CPU time to a process. Next to the priority column is the nice value (the NI column), a hint for the kernel's scheduler. This is what you care about when trying to influence the kernel's decision. The kernel adds the nice value to the current priority to determine the next time slot for the process. By default, the nice value is 0. If you want a certain process to take a backseat to other processes, running only when the other tasks have nothing to do, you can change the nice value to 19 with the renice command (where pid is the process ID of the process that you want to change):
renice 19 pid
This comes in handy when you're running some big computation in the background and don't want it to bog down your interactive session.
If you're the superuser, you can set the nice value to a negative number, but this is almost always a bad idea because system processes may not get enough CPU time. In fact, you likely won't need to alter nice values much because most Linux systems have only a single user, and that user does not perform much real computation. The nice value was much more important in the days when there were many users on a single machine.