默认的Linux调度策略是
SCHED_OTHER,它没有优先级选择,但是
nice可以在策略内部进行调整。
您必须使用函数更改为其他 计划策略
pthread_setschedparam(另请参见
man sched_setscheduler)
“常规”计划政策:(来自
sched_setscheduler(2))
SCHED_OTHER the standard round-robin time-sharing policy; SCHED_BATCH for "batch" style execution of processes; and SCHED_IDLE for running very low priority background jobs.
实时调度策略:
SCHED_FIFO a first-in, first-out policy; and SCHED_RR a round-robin policy.
在您的情况下,您可以使用,
SCHED_BATCH因为这不需要root特权。
警告: 错误使用实时调度策略可能会挂断您的系统。这就是为什么您需要root特权才能执行这种操作。
只需确定机器的功能,就可以使用包装中的
chrt工具
util-linux。
举个例子:
$ chrt -m SCHED_OTHER min/max priority : 0/0SCHED_FIFO min/max priority : 1/99SCHED_RR min/max priority : 1/99SCHED_BATCH min/max priority : 0/0SCHED_IDLE min/max priority : 0/0
一种减少 浪费 时间的方式(我经常使用):
alias batchmake='time chrt --batch 0 make --silent'
在保持用户特权的同时,这将提升
make15%(在我的情况下)。
编辑: 引入
nice,
SCHED_BATCH,
SCHED_IDLE和
chrt工具。为了准确性!:)



