改变线程并发级别会产生什么影响?

3

我正在阅读pthread_setconcurrency()的手册,但不知道“并发级别”是什么意思。这个术语太过模糊了;改变并发级别是否会改变调度策略和进程优先级?还有其他作用吗?

1个回答

4

来自Linux的手册页面

NOTES
       The default concurrency level is 0.

       Concurrency levels are only meaningful for M:N threading implementations, where at any moment a subset of a process's set  of  user-level  threads
       may be bound to a smaller number of kernel-scheduling entities.  Setting the concurrency level allows the application to give the system a hint as
       to the number of kernel-scheduling entities that should be provided for efficient execution of the application.

       Both LinuxThreads and NPTL are 1:1 threading implementations, so setting the concurrency level has no meaning.  In other  words,  on  Linux  these
       functions merely exist for compatibility with other systems, and they have no effect on the execution of a program.

1
说实话,这并没有什么帮助,因为我不知道"M:N"、"1:1"、"bound"和"kernel-scheduling entities"是什么。但既然你提到了它们,我会去查一下的。 - wmjdgla
1
我原本希望给你写一个答案。但是,最好先读一些文章。一旦你了解了线程模型,就可以轻松掌握“并发级别”的概念。http://en.wikipedia.org/wiki/Thread_(computer_science)#Models - minjang

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接