加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

linux 创建线程时设置优先级

(2013-01-25 11:40:39)
标签:

linux

线程

优先级

杂谈

分类: Linux

pthread_attr_t thread_attr;
struct sched_param schedule_param;
   
pthread_attr_init(&thread_attr);
schedule_param.sched_priority = 99;
pthread_attr_setinheritsched(&thread_attr, PTHREAD_EXPLICIT_SCHED); //有这行,设置优先级才会生效
pthread_attr_setschedpolicy(&thread_attr,SCHED_RR);
pthread_attr_setschedparam(&thread_attr, &schedule_param); 

 

pthread_create(&workerThread, &thread_attr, WorkerThreadFunction, &param);

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有