LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-19-2012, 08:57 AM   #1
eviatarkhen
LQ Newbie
 
Registered: Aug 2010
Posts: 18

Rep: Reputation: 0
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
 
Old 02-19-2012, 09:12 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
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.
 
Old 02-19-2012, 09:25 AM   #3
eviatarkhen
LQ Newbie
 
Registered: Aug 2010
Posts: 18

Original Poster
Rep: Reputation: 0
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

Last edited by eviatarkhen; 02-19-2012 at 09:45 AM.
 
Old 02-20-2012, 03:00 AM   #4
eviatarkhen
LQ Newbie
 
Registered: Aug 2010
Posts: 18

Original Poster
Rep: Reputation: 0
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically lower the priority of inactive windows Ulysses_ Linux - Desktop 3 01-26-2012 12:32 PM
process is hanging on high cpu load even if its priority is set to the maximum yucefrizk Linux - Enterprise 16 06-23-2010 02:34 AM
Sendmail using lower priority MX the_gripmaster Linux - Server 2 09-08-2008 03:41 AM
shell scripting a cpu intensive process on 2 cores dasy2k1 Linux - General 14 07-18-2008 06:20 AM
process priority,nice -- small question regarding high/low priority values beeblequix Linux - Newbie 1 10-11-2006 10:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration