Multithreaded Programming Guide


thr_setprio(3T) changes the priority of the thread, specified by tid, within the current process to the priority specified by newprio. (For POSIX threads, see "pthread_setschedparam(3T)".)

#include <thread.h>

int thr_setprio(thread_t tid, int newprio)

By default, threads are scheduled based on fixed priorities that range from zero, the least significant, to the largest integer. The tid will preempt lower priority threads, and will yield to higher priority threads.

thread_t tid;
int ret;
int newprio = 20;

/* suspended thread creation */
ret = thr_create(NULL, NULL, func, arg, THR_SUSPEND, &tid);

/* set the new priority of suspended child thread */
ret = thr_setprio(tid, newprio);

/* suspended child thread starts executing with new priority */
ret = thr_continue(tid);