Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Configurable CPU/Memory Use Script

by zek152 (Pilgrim)
on Jun 30, 2011 at 20:37 UTC ( [id://912241]=note: print w/replies, xml ) Need Help??


in reply to Configurable CPU/Memory Use Script

Just do a mix of spinwait and sleep(). Note that you will have to finetune what the ratio should be. Also in the while(1) you should put the logic to decide when the program should wake up.

Seems like a pretty big waste of CPU though. Might there be a way of running the process with a higher priority?

$sec = 0; while(1) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( +time); if($sec%2==0) { sleep(1); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://912241]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-23 23:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found