-   Programming (
-   -   Changing Process Priority in Linux w/ System Call (

sptchamp 07-20-2004 08:53 PM

Changing Process Priority in Linux w/ System Call
I'm trying to get the Linux scheduler to change the priority of a process for a certain number of timeslices by adding a system call to sched.c. I want to then later be able to pass a process pid parameter to that sys call in another *.c and change its priority for a certain # of timeslices. So given a struct task_struct with my process in it, can anyone show me any concrete example code on how I can actually change the priority of that process and only for a certain # of timeslices? I've looked on the 'net and can only find abstract ideas and procedures but nothing to aid me in actual coding.

Hko 07-21-2004 05:23 AM

In what way is it different from calling nice(2) or setpriority(2) for a certain amount of time?

jim mcnamara 07-21-2004 09:58 AM

Hko is saying there are two system calls nice() and setpriority()

I have no idea how to figure out the size of quanta (time slices) or how many have elapsed for a process without getting into the kernel.

Plus, if you want to use nice to make priority lower, you have to run privileged.

Unless you are in a realtime system, you are better off letting the scheduler figure it out for you. If you do something dumb in code and have the priority set, you can make the system unusable.

All times are GMT -5. The time now is 02:56 AM.