Changes the scheduling policy and priority of a kernel thread.
Standard C library (libc.a)
#include <sys/sched.h>
#include <sys/pri.h>
#include <sys/types.h>
int thread_setsched ( tid, priority, policy)
tid_t tid;
int priority;
int policy;
The thread_setsched subroutine changes the scheduling policy and priority of a kernel thread. User threads (pthreads) have their own scheduling attributes that in some cases allow a pthread to execute on top of multiple kernel threads. Therefore, if the policy or priority change is being granted on behalf of a pthread, then the pthreads contention scope should be PTHREAD_SCOPE_SYSTEM.
Note: Caution must be exercised when using the thread_setsched subroutine, since improper use may result in system hangs. See sys/pri.h for restrictions on thread priorities.
Upon successful completion, the thread_setsched subroutine returns a value of zero. If the thread_setsched subroutine is unsuccessful, a value of -1 is returned and the errno global variable is set to indicate the error.
The thread_setsched subroutine is unsuccessful if one or more of
the following is true:
ESRCH | The kernel thread id tid is invalid. |
EINVAL | The policy or priority is invalid. |
EPERM | The caller does not have enough privilege to change the policy or priority. |
This subroutine is part of the Base Operating System (BOS) Runtime.