Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


tickHook in tasks.c - 4.0.2

Posted by John W. on June 1, 2006

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 )

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.

John W.

RE: tickHook in tasks.c - 4.0.2

Posted by Richard on June 1, 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.


RE: tickHook in tasks.c - 4.0.2

Posted by John W. on June 1, 2006

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.

John W.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner