schedsetscheduler(2) schedsetscheduler(2)
NAME
schedsetscheduler - set the scheduling policy of a process
C SYNOPSIS
#include <sched.h>
int schedsetscheduler (pidt pid, int policy,
const struct schedparam *param);
DESCRIPTION
The schedsetscheduler system call is used to set the scheduling policy
and related parameters for the process specified by pid. If pid is set
to zero, then the scheduling policy and parameters of the calling process
will be affected.
The policy parameter is used to select one of the following scheduling
policies:
SCHEDFIFO
The first-in-first-out policy schedules processes according to
their assigned priority values. The highest priority process is
guaranteed control of the processor until it willingly yields the
processor or blocks on a contended resource. If there is more
than one runnable highest priority process, the highest priority
process waiting the longest is granted control of the processor.
A running process is preempted when a higher priority process
becomes runnable.
SCHEDRR
The round-robin scheduling policy schedules processes according
to their assigned priority values. The highest priority process
is guaranteed control of the processor until it: willingly yields
the processor, blocks on a contended resource, or exceeds its
time quantum. If there is more than one runnable highest priority
process, the highest priority process waiting the longest is
granted control of the processor. When a process exceeds its time
quantum it yields the processor and awaits rescheduling. A
running process is preempted when a higher priority process
becomes runnable.
Note that SCHED_FIFO and SCHED_RR processes are of higher priority than
all other processes in the system. Because of this, such a process may
deadlock the system if it enters an infinite loop. Further note, that
the scheduling policy and priority are inherited across a fork and that
the scheduling policy is shared by all members of a share group (see
sproc(2)).
SCHEDTS
The SCHED_TS scheduling policy is a basic timeshare scheduling
policy. All SCHED_TS processes acquire CPU resources in
proportion to their priority or nice value. Processes aquire the
processor for a time quantum, the length of which is returned via
the sched_rr_get_interval(2) system call.
Page 1
schedsetscheduler(2) schedsetscheduler(2)
SCHEDOTHER
The SCHED_OTHER scheduling policy is equivalent to the SCHED_TS
policy and allows a program to indicate that it no longer needs a
real-time scheduling policy in a portable manner.
The parameters of the selected policy are specified by the parameter
structure at address param.
The priority of the target process may be modified by setting the desired
priority value in the sched_priority field of the param structure.
Unlike IRIX 6.2 and previous releases, processes having a higher
numerical priority value are more important than processes having a lower
numerical priority value. Specified priorities remain fixed, unless
explicitly changed in the future, and are not affected by priority aging
schemes.
The priority range for these scheduling policies may be obtained via the
schedgetprioritymin(2) and schedgetprioritymax(2) function calls.
However, arbitrary priority values should not be used. Developers must
consider the needs of the application and how it should interact with the
rest of the system, before selecting a real-time priority. For more
information, see the "Real-Time Priority Band" section of realtime(5).
Runnable processes scheduled with real-time policies are always granted
processor control ahead of timeshare processes, regardless of priority.
The calling process must have superuser permissions to successfully
execute schedsetscheduler.
If the process specified by pid is currently executing or is in a
runnable state, schedsetscheduler causes the process to be rescheduled
in accordance with its priority.
If pid refers to a POSIX thread process [see pthreads(3P)] then this call
changes the scheduling policy and related parameters that are shared by
process scope threads.
schedsetscheduler will fail if one or more of the following are true:
[EINVAL] The policy argument does not represent a valid posix
scheduling policy.
[EINVAL] One of the specified parameters at address param are out
of range or scope.
[EPERM] The calling process does not have superuser permissions.
[ESRCH] The process specified by pid does not exist.
Page 2
schedsetscheduler(2) schedsetscheduler(2)
SEE ALSO
realtime(5), sched_getparam(2), sched_setparam(2), sched_getscheduler(2),
sched_yield(2), sched_get_priority_max(2), sched_get_priority_min(2),
sched_rr_get_interval(2), pthreads(5)
DIAGNOSTICS
Upon successful completion, schedsetscheduler returns the previous
scheduling policy value of the process pid.
Upon failure, a value of -1 is returned to the calling process and errno
is set to indicate the error.
Page 3