>>>is there any difference in WaitForSingleObject() in user mode and in
>> kernel mode?
There should not be any; you obviously have to care about IRQL in kernel
mode; But the function itself should behave same.
Logically, no. The major difference is that in the kernel, you supply
pointers to KEVENTs, KMUTEXes, KSEMAPHOREs, etc, (but not fast mutice,
executive resources, or spin locks). Otherwise, behavior is the same,
because all WaitFor… presumably does is convert the handles to addresses
and calls KeWaitFor…
>>If after running this app, i put my system in sleep state, does it mean
>> the timer will be off?
What do you mean by put system in sleep state? you are going to put just
the calling thread into wait state.
I presume the OP meant putting the system into sleep state, that is,
devices will get “move to D1” or “move to D2” power messages ( and the
driver may choose to move the device to D3 state). I will make no
pretensions about understanding the S-states. Power experts are free to
jump on me.
Somehow this thread tured into a discussion of how windbg breakpoints stop
the clock, which seems to have nothing to do with the original question.
Waitable timers, if I recall, have an option to force a wakeup when they
expire; this suggests that timers may be based on absolute time passing,
indpendent of the system state, but I never thought too deeply about it.
My expectation was that in the absence of the wakeup option, tiers tat
expired while the system was in wait state would not be dispatched until
wakeup. But again, this is just my opinion, based on what I thought I
understood.
When you call Sleep; the thread is going to be in wait mode; till the
associated timer is signaled. It may still not get executed even after the
timer is signaled; due to decision taken by thread scheduler. So the time
after which the thread will wake will be > time specified in API call.
But the question stated putting the /system/ into sleep state, not issuing
a Sleep API on a thread.
>>Is there any wait call can be used which is active also during sleep
>> state?
Not sure I got your motive here; If you just want to wait for a object for
a specified time; can’t you simply specify the timeout in
waitforsingleobject ?
The issue here is what happens if the WaitFor… specifies a timeout which
would expire while the system is in sleep (but not hibernate) state. I
offer my opinion that nothing happens, but that when te system returns to
an active state, it finds potentially a lot of WaitFor… calls with
expired timers, and marks those threads as “feasible to run”. Eventually,
depending on what other threads might be runnable, the WaitFor… calls
return with a timeout result code. However, this represents behavior I am
inferring from my readings, and it may not work that way at all.
As far as execution-time counters, if the system is asleep, nothing is
being executed, so my suspicion is that they will stop. Which does
suggest that if absolute time is used, it has to be determined by other
means than the system timers, but everything I’m saying is speculation,
based on my experience in a variety of other systems. Which is why I
suggested the experiment, but if one of te Micosoft folks jumps in, I hope
it will be to state what is actually perceived to happen (and not
nexessarily how this perceived behavior is implemented in various versions
of Windows or variousvplatforms).
joe
Aditya
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer