Multithreaded Programming Guide


Use pthread_setschedparam(3THR) to modify the priority of an existing thread. This function has no effect on scheduling policy.

int	 pthread_setschedparam(pthread_t tid, int policy,
    const struct sched_param *param);
#include <pthread.h>

pthread_t tid;
int ret;
struct sched_param param;
int priority;

/* sched_priority will be the priority of the thread */
sched_param.sched_priority = priority;

/* only supported policy, others will result in ENOTSUP */
policy = SCHED_OTHER;

/* scheduling parameters of target thread */
ret = pthread_setschedparam(tid, policy, &param); 

Return Values

pthread_setschedparam() returns zero after completing successfully. Any other returned value indicates that an error occurred. When either of the following conditions occurs, the pthread_setschedparam() function fails and returns the corresponding value.


The value of the attribute being set is not valid.


An attempt was made to set the attribute to an unsupported value.