One of the major benifits of linux is the way memory and processes are organised in such a way that it can be considered one of the best multi threaded operatioing systems available. Regardless of how well something can be scheduled the OS still only have a finate amount of resources to work with. My little nugget of joy today is a short description and usage by example of the nice and renice commands.
I want to write this article as i find the man pages for these commands incredibly confusing.
Niceness (as it is commonly known) is the priority that a particular task has from the perspective of the process scheduler in the kernel (i use “the” kernel as it is a common feature of most *nix like os’es)
Niceness is best imagined as a queue that ranges from -20 to 19

As you can see from the little diagram, the lower the number the higher the priority.
Most userspace applications will start with a niceness of 0 which is the most favoured niceness that a non-root user can have. Running ps wauxfl you will see the niceness of an application along with some other information such as username and a tree view of processes.
There are two ways to start a process with a different nice level. The first is at program initial execution using the nice command.
nice -4 <command>
This command will start a process with a slightly lowered niceness of 4 (less favoured) and can be run as a a normal user.
nice --4 <command>
This command has to be run as a super user. Notice the double dash (- -) this identifies that it is a switch and will have a niceness of -4 slightly raising the priority of an application above that of non root applications.
The other option for modifying the niceness of an application is renice. This tool is ported from BSD systems and as such the syntax is slightly different. Renice will let you cnange the niceness of an application that is already running.
renice +4 <pid>
This example of renice will set the niceness of <pid> to 4 lowering it’s niceness.
renice -4 <pid>
Running the command as a super user is necessary to set the niceness to less than 0 just like nice. The niceness is set to -4 in this example.
So why would you want to know about this? I personally like nice and renice as it allows you to run long and potentially resource hungry applications without stealing cpu cycles from those applications that need them. I like using nice to assist me run backups during the day or if i need something done quickly.