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




Loading

v8.2.2 - xTaskCallApplicationTaskHook() Question

Posted by westmorelandeng on August 16, 2015

Hello All,

I am using the following call:

xTaskCallApplicationTaskHook( NULL, 0 );

that goes to (example)

BaseType_t prvExampleTaskHook4( void * pvParameter )

when I step through in a debugger - the task hook is called twice - I was wondering if there was a way to have it only called once - of course this (probably) has everything to do with the parent task but I was wondering if there is a way to make sure the call only happens once per time slice of the parent task. (Or maybe the parent task in this case is getting two time slices in a row?)

Thanks, John W.


v8.2.2 - xTaskCallApplicationTaskHook() Question

Posted by rtel on August 16, 2015

Where are you calling xTaskCallApplicationTaskHook() from, and which port are you using?

If you are calling it from traceTASKSWITCHEDOUT() then some (older) ports might call it on each tick, whereas newer ports should only call it when a context switch is actually required. The way to tell would be to look at how xTaskIncrementTick() is called in the port layer. If the return value of xTaskIncrementTick() is used to determine if vTaskSwitchContext() is called then it should traceTASKSWITCHEDOUT() should not be called on each tick, if the return value is ignored then it probably will be called on each tick.

If you are using traceTASKSWITCHEDOUT() then you can update your macro definition as follows:

{
static TaskHandle_t xLastTaskHandle = NULL;

    if( pxCurrentTCB != xLastTaskHandle )
    {
        /* The task changed - run your code here. */
    }
    
    xLastTaskHandle = pxCurrentTCB;
}

Regards.


v8.2.2 - xTaskCallApplicationTaskHook() Question

Posted by westmorelandeng on August 16, 2015

I am calling xTaskCallApplicationTaskHook() in the regular task - this is defined before the for(EVER) /* Register our callback function. */ vTaskSetApplicationTaskTag( NULL, prvExampleTaskHook4 );

Well, yes, the port I am using is checking the return value of xTaskIncrementTick().


v8.2.2 - xTaskCallApplicationTaskHook() Question

Posted by westmorelandeng on August 16, 2015

OK - this is fixed - but have a related question - what is the correct way to reference pxCurrentTCB if I am not in task.c? This works fine in assembly: IMPORT pxCurrentTCB


v8.2.2 - xTaskCallApplicationTaskHook() Question

Posted by rtel on August 16, 2015

Try "extern void*". It might generate a compiler warning but should work.


v8.2.2 - xTaskCallApplicationTaskHook() Question

Posted by westmorelandeng on August 16, 2015

OK - thanks - extern PRIVILEGEDDATA TCBt * volatile pxCurrentTCB; didn't work so well. ;)


[ 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