5 int main(int argc
, char **argv
)
8 fprintf(stderr
, "Usage: %s PID SCHEDULER PRIORITY\n", argv
[0]);
9 fprintf(stderr
, "Sets the CPU Scheduler and priority for the given PID.\n See man sched_setscheduler for more information\n\n");
10 fprintf(stderr
, "SCHEDULER is one of:\n");
11 fprintf(stderr
, " 0 Other\n");
12 fprintf(stderr
, " 1 FIFO\n");
13 fprintf(stderr
, " 2 RoundRobin\n");
15 fprintf(stderr
, " 3 Batch\n");
19 int pid
= atoi(argv
[1]);
20 int priorityClass
= atoi(argv
[2]);
21 int priority
= atoi(argv
[3]);
22 printf("Setting scheduler for %d to %d %d\n", pid
, priorityClass
, priority
);
24 struct sched_param params
;
25 params
.sched_priority
= priority
;
27 switch(priorityClass
) {
29 result
= sched_setscheduler( pid
, SCHED_OTHER
, ¶ms
);
32 result
= sched_setscheduler( pid
, SCHED_FIFO
, ¶ms
);
35 result
= sched_setscheduler( pid
, SCHED_RR
, ¶ms
);;
39 result
= sched_setscheduler( pid
, SCHED_BATCH
, ¶ms
);
43 fprintf(stderr
, "Invalid Priority class\n");
47 perror("Failure setting scheduler");