多线程编程指南

pthread_setschedparam 语法

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;

policy = SCHED_OTHER;



/* scheduling parameters of target thread */

ret = pthread_setschedparam(tid, policy, &param);