MP Suspends too soon after scheduled wakeup (1 Viewer)

gloomyandy

MP Donator
  • Premium Supporter
  • September 15, 2006
    424
    14
    65
    Home Country
    United Kingdom United Kingdom
    Hi Guys,
    Right I think I'm beginning to understand what is going on! According to the following:
    http://msdn2.microsoft.com/en-us/library/aa373235.aspx
    If a system is suspended and then woken up using a timer (rather than by a user), then it will re-suspend automatically after 2 minutes unless it is "busy". This seems to match exactly what I'm seeing. For an EPG grab the system wakes up and starts the grab but after two minutes it gets suspended, if the grab has completed, if not hard luck! For recordings what seems to happen is that if the recording starts within two minutes then the recording is made ok, but then two minutes after the recording stops the system gets suspended. If it takes more than two minutes for the recording to start after the wakeup then the system suspends and the recording is missed.

    Basically to stop the automatic suspend then the application has to call SetThreadExecutionState to indicate what it is doing. MP does this as it wakes up to turn on the screen (if the option to turn on the screen is set), it also does this as part of the wakeup sequence (take a look at PowerManager.cs). But in both cases it only indicates that it is busy for a very short time, after which it indicates that it is no longer using the screen or the system by making another call to SetThreadExecutionState.

    I'm not 100% sure what the correct fix for this is. It looks like the original code in PowerManager.cs was setup to handle this case by expecting that the call to OnPowerUp would not return until the system had finished doing whatever it had woken up to do. However in the present code this simply calls the OnWakeupTimer function in PowerScheduler.cs which just writes a log entry and returns.

    Perhaps now that PowerScheduler calls its OnTimer function every 30s or so while the system is running under its control maybe it should make a call to SetThreadExecutionState(ES_SYSTEM_REQUIRED) (note no ES_CONTINUOUS) to indicate that the system cpu is still required and to prevent the system from suspending. Perhaps the correct place to call this would be whenever SetTimer is called since in this case clearly PowerScheduler is expecting that the system will continue to run until the timer goes off.

    What do you think? Are there any situations when the PowerScheduler system is not running its timer but the system is still active? Is there a better way to do this? One downside of the above is that doing this may prevent a system activated suspend from taking place (but not one that was triggered by the user). Do people use both the system suspend and PowerScheduler to suspend their system at the same time?


    I think I may give this change a try in my private build. I'll report back how it goes!

    Hope the above make sense....

    Andy
     

    ronilse

    Retired Team Member
  • Premium Supporter
  • July 19, 2005
    4,422
    283
    Moss
    Home Country
    Norway Norway
    Hi,
    Interesting because the PS works in every test & the time it's correct when hibernating/suspend after a wakeup here. Do we have different system which act difrently on a wakeup (I'm on MCE & XP Pro, using 2 different computers)?

    Regards
    Roy
     

    surfermc

    Portal Pro
    May 7, 2006
    369
    17
    Dorset
    Home Country
    England England
    Hi,
    Interesting because the PS works in every test & the time it's correct when hibernating/suspend after a wakeup here. Do we have different system which act difrently on a wakeup (I'm on MCE & XP Pro, using 2 different computers)?

    Regards
    Roy
    I'm using XP Home and according to his specifications so is gloomyandy, maybe this is the problem.

    Let's see how gloomyandy gets on with his private build.

    MC
     

    gloomyandy

    MP Donator
  • Premium Supporter
  • September 15, 2006
    424
    14
    65
    Home Country
    United Kingdom United Kingdom
    Hi Ron,
    Well I'm using XP Home. A few things that will impact if you are seeing this problem...
    1. When the system wakes up you must leave it alone. Any user input (mouse/keyboard and possibly network) will change the way it operates (it will switch out of automatic wakeup mode). Do you have a real mouse attached? I have the MS MCE keyboard only and no real mouse. I suspect that with a real mouse it may pick up vibrations that are seen as user input.
    2. If your EPG grab takes less than two minutes you may not see this problem.
    3. If your system wakes up less than two minutes before starting a recording you may not see this problem.
    4. if time to suspend settings are less than 2 minutes you may not see this problem.

    You also have to look very closely at the actual suspend times in the log files. I noticed that after a recording my system was suspending earlier than it should. Take a close look at the ps Shutdown time and the actual time the system suspends, they should be the same.

    I have my system set to wakeup 2 minutes before a recording starts, to suspend after 5 minutes of being idle and I have the recording padding set to 1 minute before the program starts.

    I've made the changes I mentioned above to my build and I'm currently testing it. I'll let you know how I get on...

    Andy
     

    gloomyandy

    MP Donator
  • Premium Supporter
  • September 15, 2006
    424
    14
    65
    Home Country
    United Kingdom United Kingdom
    Hi folks,
    First off sorry for the multiple posts. Not sure what happened! If any of you can delete the extras please do.

    Second, sorry to Roy I called you Ron!

    Third I got the wakeup time wrong I'm currently running with it set to 1 minute, not 2!

    Fourth Well I've just completed my first test and it seemed to work fine. I'm running another set of tests now.

    Andy
     

    ronilse

    Retired Team Member
  • Premium Supporter
  • July 19, 2005
    4,422
    283
    Moss
    Home Country
    Norway Norway
    Hi,
    Cleaned up a bit ;)

    Good if it works now!

    btw, many ppl call me ron, don't worry i'm used to that ;)

    I'm on wireless mouse & keyboard & the battery it's out (usually do that when testing), only remote it's used.

    I have tested with the times/settings from your log (nice to see the logs, give you exact info on div settings)

    Regards
    Roy
     

    gloomyandy

    MP Donator
  • Premium Supporter
  • September 15, 2006
    424
    14
    65
    Home Country
    United Kingdom United Kingdom
    Thanks Roy!

    Things are looking good so far. Both my tests worked. I'm out now but will try more later. MC would you be interested in trying my updated version? You would need to replace one of the dlls in your mp folder....

    If things are looking good after more tests maybe one of the devs could take a lok at my changes.

    All the best

    Andy
     

    surfermc

    Portal Pro
    May 7, 2006
    369
    17
    Dorset
    Home Country
    England England
    Thanks Roy!

    Things are looking good so far. Both my tests worked. I'm out now but will try more later. MC would you be interested in trying my updated version? You would need to replace one of the dlls in your mp folder....

    Andy,

    Yes I would be interested in giving it a try.

    MC
     

    Bavarian

    Retired Team Member
  • Premium Supporter
  • April 4, 2005
    698
    167
    Germany, Bayern
    Home Country
    Germany Germany
    A big :D to Andy, it looks like that he is right.
    I have implemented a SetThreadExecutionState call into the OnTimer routine. Can you please give the next SVN a try and post if it is fixed.

    :D



    Bavarian
     

    surfermc

    Portal Pro
    May 7, 2006
    369
    17
    Dorset
    Home Country
    England England
    Can you please give the next SVN a try and post if it is fixed.

    :D


    Bavarian
    Bavarian and Andy,

    :D for all your efforts. I've tried a couple of recordings and all seems to be working correctly. Starting when it is supposed to and powering down at the correct time. I will try with a few different settings over the coming few days and report if there are any problems.

    MC
     

    Users who are viewing this thread

    Top Bottom