in reply to CPU usage Windows OP

as tirwhan has already suggested, using the process priority to control its scheduling is your best option.

Anyway, if you still want to control yourself when the script does the heavy work, using sleep with a variable delay is a bad idea because it could end running at the worst moment, when the load in the machine is very high. A better aproach is to use something like...

while(1) { if (cpu_load() < $limit) { do_heavy() } sleep 10; }