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 ...


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 ...


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

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

I suspect that the most common use case is when you start a program with the default priority, then realize that you meant to run it with a low priority. renice can also be useful if there are certain times when you want to give certain programs a higher priority (e.g. to give the logged-in user's programs a higher priority than that of other users'), but ...


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

The usual approach is to create a wrapper script. Create a script /usr/local/bin/nicer: #!/bin/sh exec ionice -c3 nice /usr/bin/"${0##*/}" "$@" Create symbolic links for each executable that you want to execute through this wrapper, e.g. ln -s nicer /usr/local/bin/myprogram Then when you run myprogram, it will execute the script ...


1

Typically I've only looked at renice when there is a potentially long running process that could bog down the system. For instance when running ffmpeg video conversions I renice those processes so that it doesn't bog down apache for serving web requests. Now in a proper environment the ffmpeg conversions would be running on another server and could not ...


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

One step further @Jordan, Here's the elegant solution against sudo nice -n -xx su <username> -c matlab hack Note: Using username=sid, matlab meta-data dir=/var/lib/matlab, nice=-10 change at your will Create matlab meta-data dir(PERPARE) sudo mkdir /var/lib/matlab Add specified user to launch matlab & right persimisson sudo useradd ...



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