The Great Watchdog Hack

Joel Sherrill joel.sherrill at OARcorp.com
Mon Dec 9 14:11:33 UTC 2002



Chris Johns wrote:
> 
> Joel Sherrill wrote:
> 
> > Paul Evans wrote:>
> > >This isn't working, so I'm wondering where RTEMS is spending it's time
> > >during power up. Any ideas?
> >
> > Zero'ing the workspace could be a huge consumer of time.  This can be
> > disabled by the BSP via the do_zero_of_workspace of the CPU
> > Configuration Table.
> 
> Are you sure this is ok ?
> 
> When I was checking the IDLE code for changes in the printing of the IDLE label by
> the monitor I noticed a comment in cpukit/score/src/threadcreateidle.c:

It is OK if the memory has already been zeroed by something else.  Over
the years,
I have seen a variety of systems which did ensure that memory was zeroed
before
control was given to the application.  These tended to be systems with
ROM 
monitors or boot loaders but it was common enough that we decided to let
the
BSP specify if RTEMS was clearing memory twice.

For sure, the executive workspace has to be zero'ed!!!!!  Someone has to
do it but it doesn't have to be done twice.

>    /*
>     *  The entire workspace is zeroed during its initialization.  Thus, all
>     *  fields not explicitly assigned were explicitly zeroed by
>     *  _Workspace_Initialization.
>     */
> 
>    _Thread_Idle = _Thread_Internal_allocate();
> 
> Could this cause problems if the workspace is not initialised ?

Yes.  A LOT!!!

> > You could also hook each of the initialization user extension points
> > and reset it.
> 
> .. or have the timer interrupt contain a counter that is decremented until 0 and
> while not zero it hits the watchdog. Set the counter to be long enough to allow the
> initialisation to complete.

If possible just using a longer timeout for the first time would be a
possible
solution.  This would be the simplest thing.

There are some pretty easy places to stick the reset if not in a kind of
order that reflects how easy I think they would be to insert compared 
to how effective.

  + if clearing memory is the big culprit, have your own memory clear
    routine that zaps N bytes, then touches the watchdog.
  + touch it before calling rtems_initialize_executive 
  + put a hook in for every init hook to touch the watchdog (pretasking,
    predriver, postdriver, etc.)
  + let every device driver init touch the watchdog

I suspect that the big time culprit is either zapping memory or
dead time during device init.  So figure out how much those are
and work it out.  

> --
>   Chris Johns, cjohns at cybertec.com.au

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985



More information about the users mailing list