tickHook in tasks.c - 4.0.2

jwestmoreland wrote on Thursday, June 01, 2006:

Richard,

In the incrementTick task in tasks.c:

    #if ( configUSE_TICK_HOOK == 1 )
    {
        extern void vApplicationTickHook( void );

        /* Guard against the tick hook being called when the missed tick
        count is being unwound (when the scheduler is being unlocked. */
        if( uxMissedTicks == 0 )
        {
            vApplicationTickHook();
        }
    }
    #endif

I was wondering if it is ‘incorrect’ just to call tickHook directly from the tick ISR.  If the scheduler is being unwound and the tickHook is called - what’s the worst case scenario?

Note I’ve been calling tickHook from 3.X.X directly from the tick ISR and that target has been very stable.  I’m not saying it’s always correct - but it doesn’t crash and I’ve done test runs for weeks.

Thanks!
John W.

rtel wrote on Thursday, June 01, 2006:

There is no technical problem as far as I can see in calling the tick hook from directly within the ISR.  From my point of view of maintainability I want it to be within the scheduler C code so there is only one place for it to be maintained, rather than in every port.

The way V4.0.1 was calling the tick hook meant it was called both during the actual tick isr, and when the scheduler was being unsuspended.  This meant that any ticks occurring when the scheduler was suspended would result in two calls of the tick hook - once during the actual isr and then again when the scheduler was unsuspended.  I did not think this was a problem, but the way some people are using the tick hook it turned out not to be the case.  The changes in V4.0.2 guard against this scenario, and I think is more logical/expected behaviour.

Of coarse calling the hook from the portable layer as you are you would never see this issue, and the portable layer code only runs during the genuine isr.

Regards.

jwestmoreland wrote on Thursday, June 01, 2006:

Richard,

I tried calling the tickHook as you had it in 4.0.1 and it didn’t work for my port.  I’m not sure now if I told you or not.  I promptly went back to the way I had it in 3.X.X and all was well.

I agree that portability is more important here.

Thanks!
John W.