I executed some commands with nice -20
but in htop
the NI appears in red and as 19, why is this?
HTOP nice level mismatch with the nice command
htopnice
Related Solutions
Ah, it's not the systemd-logind feature where each user gets it's own cgroup. I think the change responsible here is older; they're just confusingly similar. (I searched "process group fair scheduling", thinking it might be something based on unix's "process groups" that I never really understand). Wikipedia:
The Linux kernel received a patch for CFS in November 2010 for the 2.6.38 kernel that has made the scheduler fairer for use on desktops and workstations.
When a task calls __proc_set_tty(), the process wide reference to the default group is dropped, a new task group is created, and the process is moved into the new task group. Children thereafter inherit this task group, and increase its refcount. On exit, a reference to the current task group is dropped when the last reference to each signal struct is dropped. The task group is destroyed when the last signal struct referencing it is freed. At runqueue selection time, IFF a task has no cgroup assignment, its current autogroup is used.
The feature is enabled from boot by default if CONFIG_SCHED_AUTOGROUP is selected, but can be disabled via the boot option noautogroup, and can be also be turned on/off on the fly [via
/proc/sys/kernel/sched_autogroup_enabled
: Writing0
there disables it for newly created tasks, writing1
enables it.]The primary issues solved by this are for multi-core as well as multi-cpu (SMP) systems experiencing increased interactive response times while performing other tasks that use many threads in those tasks. A simple explanation is that one will be able to still watch a video, read email and perform other typical desktop activities without glitches or choppiness while compiling the Linux kernel or a similar process such as encoding video. However, there are objections to this statement.
htop displays the process's command line with spaces between the arguments. (The first argument, argument number 0, is conventionally the command name passed by the parent process.)
A process may overwrite its command line arguments with a string of the same length or shorter. A few programs use this to convey information about the state of the program. Screen sets the first argument (command name) to uppercase in the background process that manages the sessions and leaves the usually lowercase command name in the front-end process that runs in a terminal that's attached to the session..
It's also possible to start a process with no command line arguments. It's very unusual: conventionally the first argument is the command name. But it's technically possible.
While this could be a display bug, or the effect of a command name containing carriage returns, the most likely explanation is that this process (currently) has no arguments. You can check by asking the kernel directly:
cat -A /proc/12727/cmdline; echo
This displays the arguments with control characters replaced by a visual representation. The arguments are separated by ^@
.
You can find other information by exploring /proc/12727
, for example /proc/12727/exe
is a symbolic link to the executable that's running in this process and /proc/12727/fd
shows what files the process has open. You can also display this information with lsof -p12727
.
ps l 12727
will show other information about this process, in particular its parent process ID (PPID). (You can also configure htop to show this information by activating the corresponding column in the settings.)
Best Answer
The “nice” value ranges from -20 (top priority, not nice at all to other processes) to 19 (least priority, very nice to others). When you run
nice -20
(equivalent tonice -n 20
) orsudo nice -n -42
(equivalent tosudo nice --42
) or any other value out of bounds, the nice value is moved to the bound.The red is simply coloring applied to negative values in that column, indicating high-priority (“not nice”) processes. Positive values are green, indicating low-priority (“nice”) processes.