DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

thr_setprio(THREAD)


thr_setprio -- set a thread's scheduling priority

Synopsis

   cc [options] -Kthread file
   

#include <thread.h>

int thr_setprio(thread_t tid, int prio);

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.

Parameters


tid
target thread ID

prio
priority value for tid

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(C) or priocntl(S) to find what scheduling priorities are available on your system.

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:

Return values

thr_setprio returns zero for success and an error number for failure.

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

Intro(THREAD), priocntl(S), thr_getprio(THREAD), thr_getscheduler(THREAD), thr_setscheduler(THREAD), thr_yield(THREAD)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005