LFCS · Question #806
Regarding the command: nice -5 /usr/bin/prog Which of the following statements is correct?
The correct answer is B. /usr/bin/prog is executed with a nice level of 5. This question tests understanding of the nice command and how its arguments affect the nice level of a process.
Question
Options
- A/usr/bin/prog is executed with a nice level of -5.
- B/usr/bin/prog is executed with a nice level of 5.
- C/usr/bin/prog is executed with a priority of -5.
- D/usr/bin/prog is executed with a priority of 5.
How the community answered
(26 responses)- B96% (25)
- C4% (1)
Why each option
This question tests understanding of the `nice` command and how its arguments affect the nice level of a process.
Executing with a nice level of -5 would require `nice -n -5`, and generally needs root privileges; `nice -5` as provided means to add 5 to the nice value.
When `nice` is used with a positive number, such as `nice -5`, without the `-n` option, it is interpreted as `--adjustment=5`, meaning it adds 5 to the program's default nice value (which is 0). Therefore, `/usr/bin/prog` will be executed with a nice level of 0 + 5 = 5, assigning it a lower scheduling priority.
Nice levels are an input to the scheduler that *influence* priority, but are not directly the priority value itself; a nice value of 5 means a *lower* scheduling priority, not a priority of -5.
Nice levels are an input to the scheduler that *influence* priority, but are not directly the priority value itself; a nice value of 5 means a *lower* scheduling priority, not a priority of 5.
Concept tested: Linux `nice` command nice levels
Source: https://man7.org/linux/man/man1/nice.1.html
Topics
Community Discussion
No community discussion yet for this question.