Changes the scheduling policy and priority of a kernel thread.
Standard C library (libc.a)
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.
Item | Description |
---|---|
tid | Specifies the kernel thread ID of the thread whose priority and policy are to be changed. |
priority | Specifies the priority to use for this kernel thread. The priority parameter is ignored if the policy is being set to SCHED_OTHER. The priority parameter must have a value in the range 0 to PRI_LOW. PRI_LOW is defined in sys/pri.h. See sys/pri.h for more information on thread priorities. |
policy | Specifies the policy to use for this kernel thread. The policy
parameter can be one of the following values, which are defined in sys/sched.h:
|
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:
Item | Description |
---|---|
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. |