System Resume from Suspend(PowerOff) ,有時候會出現:ERROR: Power Handler function yield to low priority thread.,google的結果都指向同一個人( Steve Maillet)的回答:
In V5.0 MS added a power down thread so that power down handlers are called on所以我知道是因為我修改了backlight powerdown function 中呼叫了有使用Sleep( )的function。
a thread instead of in the former no-thread kernel context.
The documented idea is that you can now handle synch objects in powerdown code. (There are still limits to synch objects so CloseHandle is still off limits.)
Unfortunately, they implemented this in a way that generates the error
mentioned if the driver's powerdown function blocks on a thread of lower
priority, which would be normal for an application that called into the
driver and has acquired a lock on the synch object in question.
So the upshot is that you are supposed to be able to do synch stuff in power
handlers and under light testing might even seem to work but it is virtually
guaranteed to fail at some point in the future, usually well after product
release. So don't do that.
SetThreadPriority (CurThread, 0);可以看到整個poweroff 的動作是對稱的..
SetThreadQuantum (CurThread, 0);
....
CallPowerProc (GwesPowerProc....));
CallPowerProc (PowerProc.......));
Call (CallOEMPowerOff);
CallPowerProc (PowerProc.......));
CallPowerProc (GwesPowerProc....));
....
SetThreadQuantum (CurThread, Quantum);
SetThreadPriority (CurThread, Prio);