Changes the scheduling policy and priority of a kernel thread.
Standard C library (libc.a)
int thread_setsched ( tid, priority, 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.
|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
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.