The nice
command allows you to adjust the scheduling priority ("niceness") of a program. On all Unix-like systems I've used, niceness is specified by a range of integers, where -20 is the most favourable scheduling priority, 0 is the default, and 19 is the least favourable.
Having 0 as the default niceness is intuitive enough, but why were -20 and 19 selected as endpoints of the range? Why not -128 and 127, which would exactly fit in a signed 8-bit byte? Or why not -100 to 100, which is more intuitive to decimal-minded humans, or similarly but slightly more ergonomically, -99 to 99? Was the -20 to 19 range selected arbitrarily, or does it have some relationship to the internals of the scheduler that nice
originally interfaced with? (I understand that there is no such relationship today, at least for Linux, whose scheduler uses priorities in the range 0 to 139. However, I'm interested in the historical reasons for the -20 to 19 range.)
min(127, (recent CPU usage on a scale of 0 to 15) + 50 + pp->p_nice - 20
), and priorities < 25 were reserved for processes doing uninterruptible things. So niceness had to be kind of a limited range.