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
翻译自: https://www.systutorials.com/how-to-set-process-with-lowest-priority/
qt 设置进程优先级