Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sleep has high cpu (sleep spins madly behind the scenes)

by ybiC (Prior)
on Nov 09, 2002 at 03:37 UTC ( #211611=note: print w/ replies, xml ) Need Help??


in reply to Sleep has high cpu

In addition to brothers BUU and BrowserUk's apt wisdom, you may find this node by good monk Albannach to be of interest:

"while(1){} isn't idle, it's spinning madly behind the scenes, testing 1 as often as possible."


    cheers,
    Don
    striving toward Perl Adept
    (it's pronounced "why-bick")

Update: PM Search Is Your FriendTM   8^)


Comment on Re: Sleep has high cpu (sleep spins madly behind the scenes)
Re: Re: Sleep has high cpu (sleep spins madly behind the scenes)
by UnderMine (Friar) on Nov 09, 2002 at 12:25 UTC
    Some time ago I needed to have that kind of spinning (scanning large number of connections on a chat room for activity) but under low load, in the middle of the night, the same code killed the machine.

    I found using Time::HiRes to put a micro sleep inversely proportional to the number of active connections stopped the process from spinning out of control and allowed the OS to pre-empt the loop.

    Thanks

    UnderMine

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-05-07 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (155 votes), past polls