qt 设置进程优先级_如何设置最低优先级的进程?

qt 设置进程优先级

In system, sometimes, we need backstage threads with very very low priority since it cannot preempt any normal process asks for CPU.

system中 ,有时我们需要具有非常低优先级的后台线程,因为它无法抢占任何需要CPU的常规进程

SCHED_IDLE class satisfies this requirement which has the priority lower than “nice=19” of CFS. Following code does this.

SCHED_IDLE类满足此要求,该优先级低于CFS的“ nice = 19”。 以下代码执行此操作。

241 void set_idle_priority(void) {                                                                             
 242     struct sched_param param;                                                                              
 243     param.sched_priority = 0;                                                                              
 244     int s = pthread_setschedparam(pthread_self(), SCHED_IDLE, ¶m);                                     
 245     if (s != 0) handle_error("Pthread_setschedparamerror!n");                                                 
 246 }  

Check the scheduler class after you set the process.

设置过程后,检查调度程序类。

$ chrt -p 2370
pid 2370's current scheduling policy: SCHED_IDLE
pid 2370's current scheduling priority: 0

References:
1, https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt
2, https://linux.die.net/man/2/sched_setscheduler

参考文献:
1, https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt
2, https://linux.die.net/man/2/sched_setscheduler

Answered by harryxiyou.
由harryxiyou回答。

翻译自: https://www.systutorials.com/how-to-set-process-with-lowest-priority/

qt 设置进程优先级

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值