LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Restrict a task in timely manner (http://www.linuxquestions.org/questions/programming-9/restrict-a-task-in-timely-manner-641789/)

kzr_merchant 05-12-2008 11:41 PM

Restrict a task in timely manner
 
How can we restrict n TASK in n minutes? i.e. I want to execute 100/200/300 iterations in N minutes. Either in Perl or Shell.

chrism01 05-13-2008 12:08 AM

Is this a single thread/process?

If so, usually you take a timestamp before the loop, then at the bottom of the loop you check the time until you either
1. complete all the iterations anyway
OR
2. run out of time and exit the loop.

Alternately, you can run multiple copies of a prog simultaneously using something like

nohup myprog &

inside a loop

Really need more info, there are many ways of multi-tasking.

kzr_merchant 05-13-2008 11:09 PM

Thanks for your suggesions. But this will resolve only time thing. in my problem iteration s are also variable. The iteraions are also given from comand line. How do I will control iterations in 1, 2 or 3 minutes?

chrism01 05-14-2008 12:09 AM

The point is that unless you can guarantee that the system you are on is fast enough to do any num of iterations you want in any time you specify, then you have to decide which is the most important, and build the code from point of view.

So, which is your preference?


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