Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Win32::IPC and waiting

by LittleGreyCat (Scribe)
on Aug 01, 2006 at 11:23 UTC ( #564969=perlquestion: print w/ replies, xml ) Need Help??
LittleGreyCat has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks,

a trivial question where I am 90% sure of the answer, but think it may be too obvious to be 100% clearly documented.

I have been asked if the 'wait' in 'Win32::ChangeNotify' is a true wait - i.e. sits waiting to be woken on an event using minimal CPU - or is an idle loop which repeatedly checks for the condition and uses significantly more CPU.

The documentation says that '$obj->wait($timeout)' from 'Win32::IPC' is the underlying 'wait' and that it "Waits for $obj to be signalled".

From this seems 90% certain that the process is waiting on an interrupt (which is allegedly handled quite well in Windows) but does leave the slight possibility that there is something lower down in an idle loop.

Can anyone take my certainty to 99%?
(100% defies Heisenberg)

Thanks

Dave R

Comment on Win32::IPC and waiting
Re: Win32::IPC and waiting
by syphilis (Canon) on Aug 01, 2006 at 11:59 UTC
    Looking at the Win32::IPC source, it seems that 'wait' calls the 'WaitForSingleObject' Windows API function. The MSDN documentation for that function states:

    The WaitForSingleObject function checks the current state of the specified object. If the object's state is nonsignaled, the calling thread enters the wait state. It uses no processor time while waiting for the object state to become signaled or the time-out interval to elapse.

    Best I can do.

    Cheers,
    Rob
      Thanks to both the respondents.

      Looks like I hav achieved my target 99% :-)

      Sig: Nothing succeeds like a budgie with no teeth.
Re: Win32::IPC and waiting
by jimbojones (Friar) on Aug 01, 2006 at 18:58 UTC
    Hi

    I've used the WaitForSingleObject API in native C code and it does not increase CPU load while waiting. So if Win32::IPC is using that API, I think you're good to go.

    HTH, J

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-07-30 05:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls