[英]Background threads when using pthreads (nice, priority)
I have a GUI application that's using pthreads to do some heavy background processing. 我有一个GUI应用程序,它使用pthreads进行一些繁重的后台处理。
While the background processing is running the GUI is very unresponsive and I think that this is because it's being starved of CPU time by the background threads. 在后台处理正在运行时,GUI非常无响应,我认为这是因为后台线程正在耗尽CPU时间。
On Windows you can ::SetThreadPriority(hThread, THREAD_PRIORITY_BELOW_NORMAL) on the background threads and all is well. 在Windows上你可以在后台线程上设置:: SetThreadPriority(hThread,THREAD_PRIORITY_BELOW_NORMAL),一切都很好。
However on Linux I'm using pthreads and I cannot find a good alternative. 但是在Linux上我使用的是pthreads,我找不到一个好的选择。
I've already considered; 我已经考虑过了;
I'm convinced that this is quite a common pattern for GUI apps so what have I missed? 我确信这是GUI应用程序的一种常见模式,所以我错过了什么?
Marcus. 马库斯。
EDIT: Added ::setpriority to list of options (thanks ZalewaPL) 编辑:添加:: setpriority到选项列表(感谢ZalewaPL)
Setting nice value of the background threads to something higher may help. 将后台线程的良好值设置为更高的值可能会有所帮助。
Refer to this: Nice-Level for pthreads? 请参阅: pthreads的Nice-Level?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.