マルチスレッドのプログラミング

thr_setprio の構文

thr_setprio(3C) は、tid に指定されたスレッドの優先順位を、現在のプロセス内で newprio に指定された優先順位に変更します。POSIX スレッドの場合については、pthread_setschedparam の構文」を参照してください。

#include <thread.h>

int thr_setprio(thread_t tid, int newprio)

スレッドの有効な優先順位の範囲は、スケジューリングポリシーによって異なります。

thread_t tid;
int ret;
int newprio = 20;

/* suspended thread creation */
ret = thr_create(NULL, NULL, func, arg, THR_SUSPENDED, &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);