Multithreaded Programming Guide

Getting the Thread Policy and Scheduling Parameters

pthread_getschedparam(3C) gets the scheduling policy and scheduling parameters of an individual thread.

pthread_getschedparam Syntax

int  pthread_getschedparam(pthread_t tid, int *restrict policy,
    struct sched_param *restrict 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; 

pthread_getschedparam Return Values

pthread_getschedparam() returns zero after completing successfully. Any other return 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.