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

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)


Dave R

Replies are listed 'Best First'.
Re: Win32::IPC and waiting
by syphilis (Chancellor) 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.

      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

    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://564969]
Approved by prasadbabu
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-06-25 10:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.