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

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