Hot answers tagged

6

Internal niceness levels are 0-39, but increments are positive or negative. Source. So the answer is that the numbers (positive and negative) accepted by the nice command are what get you from 20, the default level, to anywhere in the 0-39 range. So why 0-39? The specific range was what worked in the designers' original implementation. The reason more ...


4

nice launches a new command with a modified nice level (lower priority than it would have otherwise had, or higher priority if you have permission). You specify which command to launch by providing it as an argument to nice itself. nice actually execs that command, so nice itself doesn't terminate until the command does. renice changes the priority of an ...


3

I believe it actually does prioritize interactive-programs -- but perhaps not enough. Programs looses priority the longer they run, and non-interactive programs looses it quicker than interactive ones. You really shouldn't operate at close to 100% CPU-usage, if you do, perhaps you should review some things... There are two things that impact the priority ...


3

This is a job for process scheduler (also, see this). Generally, when you use any command, one can say(without going into too much detail) that you ask Linux kernel(think OS) to create a separate process that will handle its job. Now the process is put in queue, and then all processes are granted access to PC's resources. This is handled by some scheduling ...


3

A list of non-zero CPU % processes: ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm --sort=+pcpu | awk '$8!=0.0 {print}' | awk 'NR>1' To count them ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm --sort=+pcpu | awk '$8!=0.0 {print}' | awk 'NR>1' | wc -l To see this continuously updated, but them in a file called ...


2

@zuazo's answer is very informative for pulseaudio specifically. For completeness, I'll note that in the general case, there are four circumstances that can cause a process not owned by root to have a high priority: The program being run is setuid-root, and gave itself the high priority and then changed its uid. The process has the SELinux capability ...


2

PulseAudio requires higher priority than other desktop programs mainly to avoid latency problems and get a skip-free audio playback. But the process that allows PulseAudio to have a higher priority is rather complex. To get this special priority, it uses the RealtimeKit (rtkit-daemon) process. This D-Bus service allows some user programs to use real-time ...


2

The nice(2) syscall is changing the relative priority (from what it was before that syscall). But setpriority(2) is changing the absolute priority. So my understanding is that nice(x) (with x being a very small number, e.g. between 0 and 9) is the equivalent of atomically doing: // asssume both getpriority & setpriority syscalls are successful int n = ...


1

Add the user to sudoers (actually, a new file in /etc/sudoers.d, but its the same premise): niceuser ALL=NOPASSWD:/usr/bin/nice Then, as the "niceuser": niceuser@localhost $ sudo nice -n -10 command... and it does what I need (that is, my user can now increase the priority of {command ...}). It supports multiple users, etc. - use man 5 sudoers for ...


1

ps -o ni $(pidof processname) For example: ps -o ni $(pidof mysqld) # ps -o ni $(pidof mysqld) NI 15



Only top voted, non community-wiki answers of a minimum length are eligible