LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Giving a CPU intensive process lower priority (https://www.linuxquestions.org/questions/linux-software-2/giving-a-cpu-intensive-process-lower-priority-930190/)

eviatarkhen 02-19-2012 08:57 AM

Giving a CPU intensive process lower priority
 
Hi All,

From my application, written at C++, I'm using the "system("transcode_script.sh &)" function to start a bash script that does background transcoding (using ffmpeg).
As ffmpeg is very CPU intensive, I want to give this process a lower priority. How would you recommend to do that? Using dynamic priority with "nice(1)"? creating a static priority using "sched_setscheduler(2)"?
What would be the best option to suit my needs?

Thank you and best regards,

Eviatar

jhwilliams 02-19-2012 09:12 AM

nice(2) would be a way to accomplish this in C.

However, you might have better luck by linking against the ffmpeg libraries in c directly, and handling that work in a separate process/thread. Then, communicate with the the task via IPC or shared memory.

eviatarkhen 02-19-2012 09:25 AM

Thanks for the replay!

Actually I do not need to communicate with the process, as this is a background process that only transcode.
What would be the preferred nice value, assuming all my application process are 0 and the system's processes are debian default (i.e values of -19,0,5)?

Thanks again and regards,

Eviatar

eviatarkhen 02-20-2012 03:00 AM

Hi Again,

As transcoding is a VERY intensive CPU opperation, I figure that reducing the nice value may not be enough, in order to not affect the systems interactivity (not only by user, but also to network requests, as samba). Wouldn't be better to change the scheduling policy to SCHED_BATCH/SCHED_IDLE? Which is better?


All times are GMT -5. The time now is 08:20 PM.