FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [October 2011 Threads] Debug a function which used by several TasksPosted 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 TasksPosted 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 TasksPosted 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 TasksPosted 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 TasksPosted by MEdwards on October 16, 2011 The task function pointer is on the task's stack.
RE: Debug a function which used by several TasksPosted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|