| SCHED(3) | Library Functions Manual | SCHED(3) |
sched_setparam, sched_getparam,
sched_setscheduler,
sched_getscheduler,
sched_get_priority_max,
sched_get_priority_min,
sched_rr_get_interval,
sched_yield, sched_protect,
sched_setaffinity_np,
sched_getaffinity_np —
#include <sched.h>
int
sched_setparam(pid_t
pid, const struct
sched_param *param);
int
sched_getparam(pid_t
pid, struct sched_param
*param);
int
sched_setscheduler(pid_t
pid, int policy,
const struct sched_param
*param);
int
sched_getscheduler(pid_t
pid);
int
sched_get_priority_max(int
policy);
int
sched_get_priority_min(int
policy);
int
sched_rr_get_interval(pid_t
pid, struct timespec
*interval);
int
sched_yield(void);
int
sched_setaffinity_np(pid_t
pid, size_t size,
cpuset_t *cpuset);
int
sched_getaffinity_np(pid_t
pid, size_t size,
cpuset_t *cpuset);
int
sched_protect(int
priority);
Available scheduling policies (classes) are:
SCHED_OTHERSCHED_FIFOSCHED_RRThe struct sched_param contains at least one member:
SCHED_OTHER, must be
PRI_NONE; the kernel will dynamically assign
priorities to the thread based on CPU load.sched_setparam(pid,
param)sched_getparam(pid,
param)sched_setscheduler(pid,
policy, param)sched_getscheduler(pid)sched_get_priority_max(policy)sched_get_priority_min(policy)sched_rr_get_interval(pid,
interval)sched_yield()sched_setaffinity_np(pid,
size, cpuset)sched_getaffinity_np(pid,
size, cpuset)sched_protect(priority)PTHREAD_PRIO_PROTECT protocol. This function will
increase the protected priority of the caller thread to
priority if the current thread's protected priority
is smaller than priority. Multiple calls to
sched_protect() with a positive priority will
“push” a priority level to the current thread, whereas
calling sched_protect() with a
priority level of -1 will
“pop” a priority level. When the level reaches
0 (the same number of “pushes” and
“pops” have been issued) the original thread priority will
be restored.Portable applications should not use the
sched_setaffinity_np() and
sched_getaffinity_np() functions.
sched_protect(),
sched_setparam(),
sched_getparam(),
sched_rr_get_interval(), and
sched_yield() return 0 on success. Otherwise, -1 is
returned and errno is set to indicate the error.
sched_setscheduler() returns the
previously used scheduling policy on success. Otherwise, -1 is returned and
errno is set to indicate the error.
sched_getscheduler() returns the
scheduling policy on success. Otherwise, -1 is returned and
errno is set to indicate the error.
sched_get_priority_max() and
sched_get_priority_min() return the maximal/minimal
priority value on success. Otherwise, -1 is returned and
errno is set to indicate the error.
sched_setaffinity_np() and
sched_getaffinity_np() return 0 on success.
Otherwise, -1 is returned and errno is set to indicate
the error.
sched_setparam() and
sched_setscheduler() functions fail if:
EINVAL]EPERM]ESRCH]The sched_getparam() and
sched_getscheduler() functions fail if:
EPERM]ESRCH]The sched_get_priority_max() and
sched_get_priority_min() functions fail if:
EINVAL]The sched_rr_get_interval() function fails
if:
ESRCH]The sched_protect() function fails if:
sched_setaffinity_np() and
sched_getaffinity_np(), are expected to conform the
IEEE Std 1003.1-2001 (“POSIX.1”)
standard.
| August 5, 2016 | NetBSD 9.1 |