Pregunta de Linux Administration #019e3987
What is the default nice level when a process is started using the nice command?
-10
10
20
0
Explicación Oficial / Explicaciones de la Comunidad
The default nice level when a process is started using the nice command without any argument is 10.
How it Works
The nice command in Linux is used to run a process with a modified scheduling priority. The "niceness" value ranges from -20 (highest priority) to 19 (lowest priority). By default, when a process is started without nice, it inherits the nice value of its parent, typically 0. However, when you explicitly use the nice command without specifying a value, it adds a default increment of 10 to the current nice value. If the parent's nice value is 0, the resulting nice value becomes 10. This is defined by the kernel's default nice increment, which is 10.
Why the Correct Value is Right
The value 10 is correct because the nice command, when invoked without a specific nice value, applies a default increment of 10. This is documented in the nice man page: "If no increment is given, the default is 10." Thus, starting a process with nice alone results in a nice level of 10 (assuming the parent's nice is 0).
Why the Incorrect Values are Wrong
- -10: This value would represent a higher priority than normal. To achieve a negative nice value, you must explicitly specify it (e.g.,
nice -n -10 command). The default does not produce negative values. - 20: While 19 is the lowest priority (maximum niceness), 20 is outside the valid range (-20 to 19). The default increment of 10 from a base of 0 yields 10, not 20.
- 0: This is the default nice value for processes started without
nice. When usingnicewithout arguments, the nice value is increased by 10, not left at 0.