Banu Prakash
Banu Prakash

Reputation: 111

Does using setpriority() have any affect if my scheduling policy is SCHED_OTHER

My scheduling policy is SCHED_OTHER. Will the change in in nice value using setpriority() have any affect. When I used it, I dint see any difference.

Upvotes: 0

Views: 1223

Answers (2)

Jack
Jack

Reputation: 51

You can also lower dynamic priority by using nice().

Try nice(9).

    #include <unistd.h>
    int nice(int inc);  // inc = increase, added to the current nice value

Upvotes: 0

rkachach
rkachach

Reputation: 17345

The answer is no. The setpriority should not affect the process in this case. As per the documentation: http://linux.die.net/man/3/setpriority > Any processes or threads using SCHED_FIFO or SCHED_RR shall be unaffected by a call to setpriority(). This is not considered an error. A process which subsequently reverts to SCHED_OTHER need not have its priority affected by such a setpriority() call.

I'm sorry but reading carefuly the http://man7.org/linux/man-pages/man7/sched.7.html:

SCHED_OTHER: Default Linux time-sharing scheduling SCHED_OTHER can be used at only static priority 0. SCHED_OTHER is the standard Linux time-sharing scheduler that is intended for all threads that do not require the special real-time mechanisms. The thread to run is chosen from the static priority 0 list based on a dynamic priority that is determined only inside this list. The dynamic priority is based on the nice value (set by nice(2), setpriority(2), or sched_setattr(2)) and increased for each time quantum the thread is ready to run, but denied to run by the scheduler. This ensures fair progress among all SCHED_OTHER threads.

Thus, the dynamic priority of the threads is affected by the call to setpriority and it should cause changes in the scheduling (depending on the new priority value being set in the call).

Upvotes: 1

Related Questions