多线程编程指南

获取线程的优先级

pthread_getschedparam(3C) 可用来获取现有线程的优先级。

pthread_getschedparam 语法

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; 

pthread_getschedparam 返回值

pthread_getschedparam() 在成功完成之后返回零。其他任何返回值都表示出现了错误。如果出现以下情况,该函数将失败并返回对应的值。


ESRCH

描述:

tid 指定的值不引用现有的线程。