wanna restrict the cpu usage for my own script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AngryProphet
Forum Newbie
Posts: 2
Joined: Tue Sep 05, 2006 7:06 am

wanna restrict the cpu usage for my own script

Post by AngryProphet »

Our database transfer script puts the cpu usage on the server (xampp on Win2000) to 95%. This script may run in background. What I want is, that the script pauses so that the server stays available for other users. I tried with usleep(30) but the result is not very impressing. Does anybody solved a similar problem with a proper solution?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

usleep(30) is a sleep of 30 microseconds. Hardly enough time for the OS to take any amount of clock back before being interupted. I'd increase the amount you pass to it be a LOT. There's always sleep() too.
AngryProphet
Forum Newbie
Posts: 2
Joined: Tue Sep 05, 2006 7:06 am

Post by AngryProphet »

Thx, feyd.

So the idea wasn´t that bad, just the amount of time was stupid?

kk, i´ll change that.
Post Reply