pthread_setschedprio()
Set a thread's priority
Synopsis:
#include <pthread.h>
int pthread_setschedprio( pthread_t thread,
int prio );
Arguments:
- thread
- The ID of the thread that you want to set the priority for. You can get a thread ID by calling pthread_create() or pthread_self().
- prio
- The new scheduling priority.
As an extension to POSIX, you can wrap the new priority in one these macros to specify how to handle out-of-range priority requests:
- SCHED_PRIO_LIMIT_ERROR(prio) — indicate an error
- SCHED_PRIO_LIMIT_SATURATE(prio) — use the maximum allowed
priority (reach a
maximum saturation point
)
If procnto was started with a -P option ending with s or S, out-of-range priority requests by default
saturate
at the maximum allowed value.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The pthread_setschedprio() function sets the priority of thread thread to prio.
If the thread is running or runnable, the effect on its position in the ready queue depends on the direction of the modification:
- If you raise the priority, the thread becomes the tail of the ready queue for that priority.
- If you don't change the priority, the thread doesn't change position in the ready queue.
- If you lower the priority, the thread becomes the head of the ready queue for that priority.
The pthread_setschedprio() function gives you a way to temporarily raise a thread's priority and lower it again, without yielding to other threads of the same priority. This is necessary if you have to implement your own strategies for bounding priority inversion, such as priority inheritance or priority ceilings.
Returns:
- EOK
- Success.
- EINVAL
- The priority isn't valid for the scheduling policy of the specified thread.
- ENOTSUP
- The specified priority isn't supported.
- EPERM
- The calling process doesn't have the required permission; see procmgr_ability().
- ESRCH
- Invalid thread ID thread.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |