Set a thread's priority
#include <pthread.h> int pthread_setschedprio( pthread_t thread, int prio );
Use the -l c option to qcc to link against this library. This library is usually included automatically.
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.
- The priority isn't valid for the scheduling policy of the specified thread.
- The specified priority isn't supported.
- The calling process doesn't have the required permission; see procmgr_ability().
- Invalid thread ID thread.