none
How to pass Watchdog handle through consecutive/cascading apps in launch process RRS feed

  • Question

  • Consider the following:

    In my Windows CE 6R3 platform I have the following app boot sequence:

    Native app loads from HKLM\init key launch which has various WaitForAPIReady waits and then launches (via CreateProcess) a managed (.NET Compact Framework) app.

    The OS has the hardware Watchdog feature enabled but I also make use of the software watchdog via CreateWatchDogTimer and related functions.

    At the moment I configure the watchdogs separately in the native and managed apps (different names) but I was wanting to change things to use the same named watchdog so that any issue in starting the managed app that may occur before it can initialise its own watchdog can properly reset the device. These questions are born from a couple of reported times in which the managed app seems to have stalled before initialising its watchdog but the native app presumably received a true response from CreateProcess and so closed its own watchdog. I figured if I use the same watchdog and don't close it when leaving the native app I could then reboot if any issues occur that stall the handover.

    It does work to use the same name but I've noticed that if I have the first native app running by itself the board reboots the moment the native app ends. I can see this is the intended behaviour as coded in the private kernel watchdog code - when the handle is cleaned up the expiration trigger is immediately called if the watchdog was running. This has me concerned that a race condition may exist if the managed app for some reason is sluggish coming up the cleanup may occur before the managed app has a chance to claim the watchdog and prevent it from triggering the expiration scenario.

    I could put in a Sleep(5000) in the native app that waits for a while after calling CreateProcess to give time for the other app to be sure to have claimed the watchdog and carry on but I thought there may be a much more elegant way to solve this.

    Does anyone have any ideas?  And are there any technical details on CreateProcess that describe the inner workings? How far into a managed app does CreateProcess get before returning a true response? Could I put my create/start watchdog code early enough in the managed app to reliably return a fail to CreateProcess of the native app if something went wrong with the watchdog init?

    Thanks.

    Monday, February 18, 2019 9:03 AM

Answers

  • The way I would resolve it is as follows:

    In your native launcher application, create a named event "ManagedAppOK". Wait for WMGR to be ready, and launch your .NET CF application. Now wait for the "ManagedAppOK" event to become signaled. If it doesn't become signaled within a certain time out period, kill the managed application and restart, or reset the entire board.

    Inside the managed app, open the named event "ManagedAppOK" and once your managed application is all up and running, signal the event.

    That elegant enough?



    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: https://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    NXP Proven Partner
    https://guruce.com
    Consultancy, training and development services.

    Interested in WEC on i.MX6?
    Get the only 100% stable and best performing i.MX6 BSP for WEC7 and WEC2013 here: https://guruce.com/imx6

    • Marked as answer by BBBB10100 Tuesday, February 19, 2019 3:52 AM
    Monday, February 18, 2019 11:46 AM
    Moderator

All replies

  • The way I would resolve it is as follows:

    In your native launcher application, create a named event "ManagedAppOK". Wait for WMGR to be ready, and launch your .NET CF application. Now wait for the "ManagedAppOK" event to become signaled. If it doesn't become signaled within a certain time out period, kill the managed application and restart, or reset the entire board.

    Inside the managed app, open the named event "ManagedAppOK" and once your managed application is all up and running, signal the event.

    That elegant enough?



    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: https://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    NXP Proven Partner
    https://guruce.com
    Consultancy, training and development services.

    Interested in WEC on i.MX6?
    Get the only 100% stable and best performing i.MX6 BSP for WEC7 and WEC2013 here: https://guruce.com/imx6

    • Marked as answer by BBBB10100 Tuesday, February 19, 2019 3:52 AM
    Monday, February 18, 2019 11:46 AM
    Moderator
  • Hi Michel,

    That's exactly what I was looking for. No race conditions in this method. I've implemented it today without any problems.

    Thank you.


    Tuesday, February 19, 2019 3:53 AM