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)
Scheduler Policy is 6.
Can someone explain which return int value from sched_getscheduler(pid) corresponds to which scheduler policy?
For example: From the aforementioned code I believe 6 corresponds to SCHED_DEADLINE policy.
You can find out things like this easily yourself on your system like for example that: