多线程编程指南

pthread_attr_setschedparam 语法

int	pthread_attr_setschedparam(pthread_attr_t *tattr,

    const struct sched_param *param);
#include <pthread.h>



pthread_attr_t tattr;

int newprio;

sched_param param;

newprio = 30;



/* set the priority; others are unchanged */

param.sched_priority = newprio;



/* set the new scheduling param */

ret = pthread_attr_setschedparam (&tattr, &param); 

调度参数是在 param 结构中定义的。仅支持优先级参数。新创建的线程使用此优先级运行。