设为首页 加入收藏

TOP

6.7.4 设置线程的竞争范围
2013-10-07 12:59:09 来源: 作者: 【 】 浏览:66
Tags:6.7.4 设置 线程 竞争 范围

6.7.4  设置线程的竞争范围

线程的竞争范围决定了线程同哪些其他线程竞争处理器的使用。竞争范围是由线程属性对象设置的。

调用形式

  1. #include <pthread.h> 
  2.                 
  3. int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);  
  4. int pthread_attr_getscope(const pthread_attr_t *restrict attr,  
  5.                          int *restrict contentionscope); 

pthread_attr_setscope( )设置由attr指定的线程属性对象的竞争范围属性。线程属性对象的竞争范围会设置为保存在contentionscope中的值。contentionscope可以为以下值。

PTHREAD_SCOPE_SYSTEM:系统调度竞争范围

PTHREAD_SCOPE_PROCESS:进程调度竞争范围

系统竞争范围意味线程同系统范围内其他进程的线程进行竞争。pthread_attr_getscope( )从attr指定的线程属性对象返回竞争范围属性。如果函数成功,则返回线程属性对象的竞争范围,并保存到contentionscope中。这两个函数如果成功则返回0,否则返回错误号。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇6.4.3 调度策略和优先级 下一篇6.6.4 使用pthread属性对象

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: