thr_setprio(3thread) thr_setprio(3thread)
NAME
thr_setprio - set a thread's scheduling priority
SYNOPSIS
cc [options] -Kthread file
#include <thread.h>
int thr_setprio(thread_t tid, int prio);
Parameters
tid target thread ID
prio priority value for tid
DESCRIPTION
thr_setprio sets tid's scheduling priority to be prio.
thr_setscheduler can also be used to set the priority of a
thread, but thr_setprio is a shorthand for use when only the
priority, not the scheduling class, needs to be changed.
For bound threads, the priority set with thr_setprio is passed
to the system scheduler; it is not maintained by the Threads
Library. For multiplexed threads, the priority set with
thr_setprio is used by the Threads Library in scheduling
multiplexed threads to run on LWPs. The priorities for
multiplexed threads remain fixed (unless explicitly changed
with thr_setscheduler or thr_setprio), and the Threads Library
assigns higher priority threads to LWPs before lower priority
threads.
Priority Range for Multiplexed Threads
In this implementation, the priority range for the SCHED_TS
policy for multiplexed threads is from zero to MAXINT-1.
However, for better performance we recommend using a maximum
priority of 126 or lower. The default priority for
multiplexed threads is 63.
In all scheduling policies supported by this implementation,
numerically higher values represent higher priorities.
Priority Range for Bound Threads
Bound threads running under any scheduling policy are subject
to the priority ranges set by the system. Use priocntl(1) or
priocntl(2) to find what scheduling priorities are available
on your system.
Copyright 1994 Novell, Inc. Page 1
thr_setprio(3thread) thr_setprio(3thread)
Security Restrictions
No privileges or special permissions are required to use
thr_setprio to set the priority of a multiplexed thread. The
following rules apply to changing the priority of bound
threads:
You can always lower the priority of any bound thread.
You can always raise the priority of bound threads in
the SCHED_FIFO and SCHED_RR classes.
You must have privilege to raise the priority of a bound
thread in the SCHED_TS class. The required privileges
may vary across installations.
Return Values
thr_setprio returns zero for success and an error number for
failure, as described below.
Errors
If any of the following error conditions is detected,
thr_setprio fails and returns the corresponding value:
EINVAL The value of prio is invalid for tid's current
scheduling policy.
EPERM The caller does not have appropriate privilege to set
the priority of tid.
ESRCH No thread with identifier tid can be found in the
process.
REFERENCES
priocntl(2), thr_getprio(3thread), thr_getscheduler(3thread),
thr_setscheduler(3thread), thr_yield(3thread), thread(3thread)
Copyright 1994 Novell, Inc. Page 2