Currently, Linux supports the following "normal" (i.e., non-real-time) scheduling
policies as values that may be specified in policy:
SCHED_OTHER the standard round-robin time-sharing policy;
SCHED_BATCH for "batch" style execution of processes; and
SCHED_IDLE for running very low priority background jobs.
For each of the above policies, param->sched_priority must be 0.
Various "real-time" policies are also supported, for special time-critical appli‐
cations that need precise control over the way in which runnable threads are se‐
lected for execution. For the rules governing when a process may use these poli‐
cies, see sched(7). The real-time policies that may be specified in policy are:
SCHED_FIFO a first-in, first-out policy; and
SCHED_RR a round-robin policy.
For each of the above policies, param->sched_priority specifies a scheduling pri‐
ority for the thread. This is a number in the range returned by calling
sched_get_priority_min(2) and sched_get_priority_max(2) with the specified policy.
On Linux, these system calls return, respectively, 1 and 99.
...
...
...
EINVAL (sched_setscheduler()) param does not make sense for the specified policy.
Thus SchedPriority is only meaningful for FIFO & RR policy. This PR tries addressing this bug by using sched_priority value in set_policy() only when the policy is a real-time one.
By stracing system76-scheduler daemon, it could be found that most calls to
sched_setscheduler()
returns EINVAL:In
sched_setscheduler(2)
it says that:Thus
SchedPriority
is only meaningful for FIFO & RR policy. This PR tries addressing this bug by using sched_priority value inset_policy()
only when the policy is a real-time one.