I am new to OS programming. So, I wrote this code to change the scheduling policy of a background process, whose process ID I supply through a command line argument, but the sched_setscheduler() function fails, giving an error, "Function not implemented"
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
struct sched_param param;
param.sched_priority = 80;
int pid = atoi(argv[1]);
int policy = sched_getscheduler(pid);
printf("Current policy: %d\n", policy);
if(sched_setscheduler(pid, SCHED_FIFO, ¶m) == -1){
perror("Scheduler policy cannot be set");
}
int new_policy = sched_getscheduler(pid);
printf("New policy: %d\n", new_policy);
}
Can someone please tell me why this happening? Thanks.