Powered By Blogger
Sunday, June 7, 2009

Keeping system alive

In power manager, the PDD has a certain set of events that it monitors. For eg:

  • PM_BOOTPHASE2_EVENT
  • PM_SYSTEM_API_EVENT etc
For more information on events each PDD handles, check the Power manager code available in PUBLIC code (WINCE600\PUBLIC\COMMON\OAK\DRIVERS\PM\PDD).

In those events there is event PM_SYSTEM_TIMEIDLE_RESET (PowerManager/SystemIdleTimerReset), which can used to reset the system activity timer. Check out the following piece of code for doing so.


HANDLE hSysTmrReset = CreateEvent(NULL, FALSE, FALSE, _T("PowerManager/SystemIdleTimerReset"));
BOOL bExit = FALSE;
if (INVALID_HANDLE_VALUE != hSysTmrReset )
{
while (FALSE == bExit)
{
ResetEvent(hSysTmrReset);
Sleep(1000);
SetEvent(hSysTmrReset);

RETAILMSG(TRUE, (TEXT("Reset\r\n")));
Sleep(20000);
}
CloseHandle (hSysTmrReset );
}
return 0;

This system, code will keep the system alive by resetting the timer every 20 seconds. I have tested this code and seems to be working. But needs to analyze the system performance on doing so.

0 comments: