[英]What scheduling policy does each return int value from sched_getscheduler(pid) correspond to? [C]
When I use the following code to set the scheduling policy to Deadline: 当我使用以下代码将调度策略设置为“截止日期”时:
struct sched_attr attr = {
.size = sizeof(attr),
.sched_policy = SCHED_DEADLINE,
.sched_runtime = 30000000,
.sched_period = 100000000,
.sched_deadline = 100000000
};
pid_t pid = getpid();
printf("pid=(%d)\n",pid);
if (sched_setattr(pid, &attr, 0)){
printf("[ERROR] sched_setattr()\n");
perror("[ERROR] sched_setattr()\n");
}
// Check scheduler policy is set correctly
printf("Scheduler Policy is %d.\n", sched_getscheduler(pid));
The result of the aformentioned code is as follows: 上述代码的结果如下:
pid=(XXXXXX) pid =(XXXXXX)
Scheduler Policy is 6. 计划程序策略为6。
Can someone explain which return int value from sched_getscheduler(pid) corresponds to which scheduler policy? 有人可以解释sched_getscheduler(pid)的哪个返回int值对应于哪个调度程序策略吗?
For example: From the aforementioned code I believe 6 corresponds to SCHED_DEADLINE policy. 例如:从上述代码中,我相信6对应于SCHED_DEADLINE策略。
You can find out things like this easily yourself on your system like for example that: 您可以自己在系统上轻松找到类似这样的内容,例如:
$ grep -r SCHED_DEADLINE /usr/include/
/usr/include/linux/sched.h:
#define SCHED_DEADLINE 6
$ grep define.SCHED_ /usr/include/linux/sched.h
#define SCHED_NORMAL 0
#define SCHED_FIFO 1
#define SCHED_RR 2
#define SCHED_BATCH 3
#define SCHED_IDLE 5
#define SCHED_DEADLINE 6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.