Is it possible to control cpu usage using Perl script in an idle machine?
like some.pl 50 will consume 50% cpu, some.pl 100 will consume 100% cpu usage.
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.
Yes, certainly it is possible. The following snippet calculates the percentage of processor load for a certain process in an instant of time. You probably first want to collect a certain number of values and average them for a smooth result.
Then simply, if the load is not high enough, tell the process to do work, if the load is too high, tell the process to pause work.