Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


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 ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists