Multithreaded Programming Guide

Get the Thread Priority


pthread_getschedparam(3T) gets the priority of the existing thread.

int	 pthread_getschedparam(pthread_t tid, int policy,
    struct schedparam *param);
#include <pthread.h>

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

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

/* sched_priority contains the priority of the thread */
priority = param.sched_priority; 

Return Values

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


The value specified by tid does not refer to an existing thread.