Main Content

Linux / Unix - process priority and nice

Archive - Originally posted on "The Horse's Mouth" - 2007-01-10 23:12:26 - Graham Ellis

Visit certain theme parks, stand in queues for the rides. OK - that's fair enough at time. But then see folks with "fast pass" special tickets go the front and get, more or less, straight on. You may have seen the scenario ....

But look carefully, and the operators never let the whole of the fast-track bunch through at once. If there's a queue there too, they'll clear it rapidly, but still keep a modicum of flow running from the main lines.
A similar thing happens with Linux / Unix tasks that are awaiting the processor - known as "runnable"s. There's a concept known as "niceness". Default value 0 - standard queue. Positive value - a process that is nice to others and hold back, so lower priority. And a negative value - a process that barges in and gets higher priority treatment.

But there's NOT an absolute rule that runnables are started are run without limit in the order "least nice first" - there has to be some sharing and although the higher priority processes will be kept waiting far less, they will be kept waiting on occasions.