Quality RTOS & Embedded Software

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


Loading

Debug a function which used by several Tasks

Posted by Samuel on October 14, 2011
Does anyone know how to debug function which used by several tasks? For example:

xTaskCreate( prvTest, ( signed char * ) "Test1", 100, ( void * )Parameters, 2, NULL );
xTaskCreate( prvTest, ( signed char * ) "Test2", 100, ( void * )Parameters, 2, NULL );

static prvTest( void* pvParameters)
{
...
for( ;; )
{
aFunction();
bFunction(); //Add breakpoint here...
cFunction();
}
}

prvTest() is the function used by two tasks, I put a breakpoint at "bFunction() ", if the debugger stop at "bFunction()", how can I know it is in task "Test1" or task "Test2"?

Regards
Samuel

RE: Debug a function which used by several Tasks

Posted by Richard on October 15, 2011
Look at the pxCurrentTCB variable in the debugger. It points to the TCP of the currently running task, so its values will be different for both tasks, and in fact equal to the handle of the task. Further, if you inspect the TCB structure in the debugger you will see the human readable name of the task "Test1" or "Test". You might have to cast the variable to see the structure, depending on your debugger ( (tskTCB*)pxCurrentTCB ).

If you are using Eclipse, IAR or Keil tools, then depending on your tool version and MCU being used, you can use the kernel aware plug in to see which task is in the Running state too.

Regards.

RE: Debug a function which used by several Tasks

Posted by Samuel on October 16, 2011
Hi Richard,

Your reply make senses. pcTaskName element in the pxCurrentTCB structure display the tasks.

Another question, where element in the "pxCurrentTCB" structure contains the pointer to the task functions?
For example, there are two task2, "Test1" and "Test2".
xTaskCreate( prvTest1, ( signed char * ) "Test1", 100, ( void * )Parameters, 2, NULL );
xTaskCreate( prvTest2, ( signed char * ) "Test2", 100, ( void * )Parameters, 2, NULL );

setup Taks: signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName,...

Setup the task function "pxTaskCode": pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters );

Add the list to pxReadyTasksLists[ configMAX_PRIORITIES ]: prvAddTaskToReadyQueue( pxNewTCB );

But I can't work out how the task function pointer map to "pxCurrentTCB".

Regards
Samuel

RE: Debug a function which used by several Tasks

Posted by Samuel on October 16, 2011
I am using IAR workbench, the RTOS is for ARM Cortex-M3.

RE: Debug a function which used by several Tasks

Posted by MEdwards on October 16, 2011
The task function pointer is on the task's stack.

RE: Debug a function which used by several Tasks

Posted by Samuel on October 17, 2011
I ask the question "how the task function pointer map to "pxCurrentTCB", because I would like to know how the switch each tasks.


1. after ISR: xPortPendSVHandler ===>vTaskSwitchContext() ==> listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) ==> Where does the call to the pointer to next task??

2. "pxCurrentTCB", would you please expian the functions of those element? are those related pointer to next task?
pxCurrentTCB.xGenericListItem.pVOwner
pxCurrentTCB.xGenericListItem.pVContainer

pxCurrentTCB.xEventListItem.pVOwner
pxCurrentTCB.xEventListItem.pVContainer


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 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.


Careers

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

Renesas

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