The following is what i am trying to do but i am not able to change the priority of the scheduler .. I am only able to change the policy using sched_setscheduler. I have running it in SU.
int sched_setpriority(pid_t pid, int priority)
{
struct sched_param p;
int min_pri, range_pri;
p.sched_priority = priority;
return sched_setscheduler(pid, SCHED_FIFO, &p);
}
int sched_getsched(pid_t pid)
{
return sched_getscheduler(pid);
}
int sched_getpriority(pid_t pid)
{
return getpriority(PRIO_PROCESS, pid);
}
int main ()
{
pid_t proc ;
proc = getpid();
int i, j, s;
i = sched_getsched(proc);
j = sched_getpriority(proc);
printf("My current sched is %d\nMy current pri is %d\n\n", i, j);
s = sched_setpriority(proc, 99);
if(s)
{
perror("Set Priority -- \n");
}
i = sched_getsched(proc);
j = sched_getpriority(proc);
printf("My new sched is %d\nMy new pri is %d\n\n", i, j);
}
|