1

Although I can see a "nice" value ("NI") via ps, it seems to have no effect on the actual cpu-time used by a process:

  PID  %CPU PRI NI COMM
57081  77.6  12 10 cpu-chew
57080  77.1  12  0 cpu-chew
57085  76.9  12 15 cpu-chew
57082  76.9  12 13 cpu-chew
57083  76.7  12  0 cpu-chew
57031   0.0  31  0 -tcsh

Does anybody have any idea how I can actually get one process to receive more CPU than another?

== Further info, fwiw:

MacOS 10.12.6

I get the same behavior if I try (re)nice'ing with a negative value, and also if I go up to more than more than 32 processes (just to make sure I'm maxing out "hyperthreads" or anything).

cpu-chew is a short C program that just does square-rooting and incrementing (see below).

Running 'ps' multiple times gives the processes in a slightly different order, and with a varying PRI value (from 1-ish to 14-ish), but all cpu-chew copies will have roughly the same PRIority. I gather that PRI incorporates some sort of age mechanism to account for time-since-last-switched-in.)

Here's the full transcript of me starting the jobs via different combinations of nice and renice:

tropic: cpu-chew &
tropic: /usr/bin/nice cpu-chew &
tropic: /usr/bin/nice -n 13 cpu-chew &
tropic: cpu-chew &
tropic: cpu-chew &
tropic: ps -rc -o pid,pcpu,pri,nice,comm

  PID  %CPU PRI NI COMM
57085  78.2   1  0 cpu-chew
57083  78.0   2  0 cpu-chew
57081  77.4   3 10 cpu-chew
57080  77.2   2  0 cpu-chew
57082  76.7   2 13 cpu-chew
57031   0.0  31  0 -tcsh

tropic: /usr/bin/renice -n 15 57085
tropic: ps -rc -o pid,pcpu,pri,nice,comm

  PID  %CPU PRI NI COMM
57081  77.6  12 10 cpu-chew
57080  77.1  12  0 cpu-chew
57085  76.9  12 15 cpu-chew
57082  76.9  12 13 cpu-chew
57083  76.7  12  0 cpu-chew
57031   0.0  31  0 -tcsh

And further tangential stuff:

tropic: cat cpu-chew.c

#include <math.h>

int main() {
    double i=2;
    while (i != sqrt(i)) 
        ++i;
    }

Running limit doesn't show anything odd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.