SCHED_SETSCHEDULER(2)

NAME
sched_setscheduler - Set scheduling policy/parameters for a process

SYNOPSIS
# include <sched.h>

int sched_setscheduler ( pid_t pid, int policy, const struct sched_param *p )

DESCRIPTION
The function sched_setscheduler sets the scheduling policy (algorithm) and scheduler parameters for a process given by pid to the policy specified by policy and to the parameters specified by p. If the pid is 0, the policy and parameters are applied to the calling process. Depending on the scheduling policy specified different members of p may be used. This implementation of POSIX.4 defines the following scheduling policies and the valid members of the sched_param structure.

SCHED_FIFO      sched_priority

SCHED_RR        sched_priority

On a successful call to sched_setscheduler, the system updates the priority of the process and forces a reschedule (if required).

RETURN VALUE
On a failure sched_setscheduler returns -1 with errno indicating the error, otherwise 0.

ERRORS
When sched_setscheduler fails, errno will be set to one among the following values:

EINVAL
    The calling process has not provided a valid policy value -- specified by POSIX.4 to be SCHED_FIFO, SCHED_RR or SCHED_OTHER.

EINVAL
    The calling process has not provided a valid sched_param structure.

EINVAL
    The sched_priority being set for a process with a scheduling policy of SCHED_FIFO or SCHED_RR is greater than the value returned by sched_get_priority_max() or less than the value returned by sched_get_priority_min() for the scheduling policy being set.

ESRCH
    The process specified by a non-zero pid does not exist on the system.

EPERM
    The calling process cannot affect the scheduling parameters of the process given by pid because it lacks authority. Under Linux, a process must be the same uid as the caller or the caller must be superuser.

SEE ALSO
sched_getparam(2), sched_setparam(2), sched_get_priority_min(2), sched_get_priority_max(2), sched_rr_get_interval(2), sched_getscheduler(2)