linux – pthread_create():什么是默认优先级和shceduling策略

linux – pthread_create():什么是默认优先级和shceduling策略,第1张

概述惠普手册页( link)说 “By default, the new thread’s scheduling policy and priority are inherited from the creating thread—that is, by default, the pthread_create(3) routine ignores the scheduling policy and p 惠普手册页( link)说

“By default,the new thread’s scheduling policy and priority are
inherited from the creating thread—that is,by default,the
pthread_create(3) routine ignores the scheduling policy and priority
set in the specifIEd thread attributes object. Thus,to create a
thread that is subject to the scheduling policy and priority set in
the specifIEd thread attributes object,before calling
pthread_create(3) your program must use the
pthread_attr_setinheritsched(3) routine to set the inherit thread
attributes object’s scheduling attribute to PTHREAD_EXPliCIT_SCHED.”

这适用于linux posix线程(NPTL pthread)吗?

如果没有,影响使用pthread_create()创建的线程的优先级和调度策略的因素是什么?

解决方法 从 here开始:

The following values may be specifIEd in inheritsched:

PTHREAD_inherit_SCHED
Threads that are created using attr inherit scheduling attributes from the creating thread; the scheduling attributes in attr are ignored.

PTHREAD_EXPliCIT_SCHED
Threads that are created using attr take their scheduling attributes from the values specifIEd by the attributes object.

The default setting of the inherit scheduler attribute in a newly initialized thread attributes object is PTHREAD_inherit_SCHED.

因此,似乎与问题中描述的行为相同.

我实际上已经认为这个默认值可以由标准定义(虽然我没有那么多经验,但我承认),但是看看Thread Scheduling Attributes部分的最后一行:

(…) The default values of other scheduling attributes are implementation-defined.

总结

以上是内存溢出为你收集整理的linux – pthread_create():什么是默认优先级和shceduling策略全部内容,希望文章能够帮你解决linux – pthread_create():什么是默认优先级和shceduling策略所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1049989.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存