sched_setscheduler(S-osr5)
sched_setscheduler --
set scheduling policy
Syntax
cc . . . -lc
#include <sched.h>
int sched_setscheduler(pid_t pid, int policy, const struct sched_param
*param);
Description
sched_setscheduler sets the scheduling policy of the process
specified by pid to policy and the scheduling parameters
to param.
If pid is 0, the policy and parameters are set for the calling
process.
The following policies are available:
SCHED_FIFO-
first in first out. Processes are allowed on the CPU in the order in which
they were added to the queue of processes to be run, for each priority.
SCHED_RR-
round-robin. Identical to SCHED_FIFO except that a process
runs only for a set time slice (see
sched_rr_get_interval(S-osr5)).
Once the
process has completed its time slice it is placed on the tail of the queue of
processes to be run, for its priority.
SCHED_OTHER-
non-realtime scheduling. This uses the traditional UNIX scheduler.
On MPX systems, if pid specifies a process currently
running on a different CPU then the
process specified by pid will be taken off the CPU.
This is the equivalent of the process specified by pid making a
call to sched_yield.
The process which made the call to sched_setscheduler will
sleep while this occurs.
Return values
Upon successful completion sched_setscheduler returns the previous
scheduling policy of the process specified by pid. If an error has
occurred the policy and scheduling parameters of the target process will
remain unchanged, sched_setparam returns -1, and errno is
set to indicate the error.
Diagnostics
If sched_setscheduler terminates due to an error, it will set
errno to one of the following values:
[EINVAL]-
One or more of the scheduling parameters specified is out of the range
defined for the specified process's scheduling policy, or the specified policy
is incorrect.
[ENOSYS]-
The function is not supported.
[EPERM]-
The requesting process does not have permission to set either or both of the
scheduling parameters, or the scheduling policy of the process specified
by pid.
[ESRCH]-
The process, specified by pid, does not exist.
Examples
The following example illustrates the use of sched_setscheduler:
struct sched_param sp;
int policy;
...
if((policy = sched_getscheduler(0) == -1)) {
fprintf(stderr, ...
}
if(policy == SCHED_OTHER) {
sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
sched_setscheduler(0, SCHED_FIFO, &sp)
...
}
...
Files
/usr/lib/libc.a-
linking library
See also
sched_get_priority_max(S-osr5),
sched_getparam(S-osr5),
sched_getscheduler(S-osr5),
sched_rr_get_interval(S-osr5),
sched_setparam(S-osr5),
sched_yield(S-osr5)
Standards conformance
Text reprinted and/or adapted from IEEE Std
1003.1b-1993, IEEE Standard for Information
Technology, POSIX Part 1: System Application
Program Interface (API) Amendment 1: Realtime
Extensions [C Language], copyright © 1993 by the
Institute of Electrical and Electronics Engineers, Inc. The
IEEE takes no responsibility for and will assume
no liability for damages resulting from the reader's
misinterpretation of said information resulting from the
placement and context in this publication. Information is
reproduced with the permission of the IEEE.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005