From 267efe0b88ee98eca65d3171d44b49e80c10516c Mon Sep 17 00:00:00 2001 From: peabody124 Date: Thu, 3 Mar 2011 04:28:22 +0000 Subject: [PATCH] OP-315: Patch to FreeRTOS port to allow querying the run time for tasks. This will need to be forward ported (and ideally pushed up stream) for FreeRTOS updates git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2939 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../Libraries/FreeRTOS/Source/include/task.h | 13 +++++++++++++ .../STM32F10x/Libraries/FreeRTOS/Source/tasks.c | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/include/task.h b/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/include/task.h index 1f29ef46f..cfc1b3d2f 100755 --- a/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/include/task.h +++ b/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/include/task.h @@ -1114,6 +1114,19 @@ unsigned long ulTaskEndTrace( void ) PRIVILEGED_FUNCTION; */ unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask ) PRIVILEGED_FUNCTION; +/** + * task.h + *
unsigned portBASE_TYPE uxTaskGetRunTime( xTaskHandle xTask );
+ * + * Returns the run time of selected task + * + * @param xTask Handle of the task associated with the stack to be checked. + * Set xTask to NULL to check the stack of the calling task. + * + * @return The run time of selected task + */ +unsigned portBASE_TYPE uxTaskGetRunTime( xTaskHandle xTask ); + /* When using trace macros it is sometimes necessary to include tasks.h before FreeRTOS.h. When this is done pdTASK_HOOK_CODE will not yet have been defined, so the following two prototypes will cause a compilation error. This can be diff --git a/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c b/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c index 120f8f7e3..85089740a 100755 --- a/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c +++ b/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c @@ -2175,6 +2175,18 @@ tskTCB *pxNewTCB; #endif /*-----------------------------------------------------------*/ +#if ( INCLUDE_uxTaskGetRunTime == 1 ) +unsigned portBASE_TYPE uxTaskGetRunTime( xTaskHandle xTask ) +{ + tskTCB *pxTCB; + pxTCB = prvGetTCBFromHandle( xTask ); + return pxTCB->ulRunTimeCounter; +} + +#endif + +/*-----------------------------------------------------------*/ + #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) static unsigned short usTaskCheckFreeStackSpace( const unsigned char * pucStackByte )