I am new in Linux and system programming .
I Want to write a c program which finds processes whose cpu% usage are more than a specific given value and sends them to background.
anybody can help me !
I really appreciate it
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m fairly sure that what you’re asking is that you want to detect if a process is using X amount of CPU and if so, take it off the CPU for a while. There’s a piece of software already that does this: It’s called the kernel. I’m not aware of any way to programatically take another process off CPU unless that other program supports an external interface to reduce its load.
Most likely what you really want to do is configure the
niceand other scheduler parameters of the running process so the kernel is more like to to take it off CPU when another program needs to do work.But what underlying problem are you really trying to solve here? Maybe if you tell us that we can offer an alternate solution.