Created
July 19, 2015 21:54
-
-
Save mayli/9e03652c47117390cf78 to your computer and use it in GitHub Desktop.
play with SCHED_RR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <errno.h> | |
#include <sched.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
void print_sched(){ | |
printf("PID=%d, SCHED=%d\n", getpid(), sched_getscheduler(getpid())); | |
} | |
int set_sched(int policy, int priority){ | |
int ret; | |
struct sched_param param; | |
param.sched_priority = priority; | |
ret = sched_setscheduler(getpid(), policy, ¶m); | |
if (ret) | |
perror("sched_setscheduler"); | |
return ret; | |
} | |
int main(){ | |
print_sched(); | |
printf("sched_setscheduler()->%d\n", set_sched(SCHED_RR, sched_get_priority_max(SCHED_RR))); | |
print_sched(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment