From: richardbarry Date: Thu, 6 Jan 2011 10:08:07 +0000 (+0000) Subject: Introduce the portALT_GET_RUN_TIME_COUNTER_VALUE macro as an alternative to portGET_R... X-Git-Tag: V6.1.1~27 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c8d40e712be8506c2f374c29178f5ed673b9bb15;p=freertos Introduce the portALT_GET_RUN_TIME_COUNTER_VALUE macro as an alternative to portGET_RUN_TIME_COUNTER_VALUE to make inlining of the run time stats functions easier. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1230 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/include/FreeRTOS.h b/Source/include/FreeRTOS.h index 6a4097cc7..5b0a99609 100644 --- a/Source/include/FreeRTOS.h +++ b/Source/include/FreeRTOS.h @@ -33,9 +33,9 @@ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained by writing to Richard Barry, contact details for whom are available on the FreeRTOS WEB site. @@ -239,17 +239,17 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #endif #ifndef traceBLOCKING_ON_QUEUE_RECEIVE - /* Task is about to block because it cannot read from a + /* Task is about to block because it cannot read from a queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the read was attempted. pxCurrentTCB points to the TCB of the + upon which the read was attempted. pxCurrentTCB points to the TCB of the task that attempted the read. */ #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) #endif #ifndef traceBLOCKING_ON_QUEUE_SEND - /* Task is about to block because it cannot write to a + /* Task is about to block because it cannot write to a queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore - upon which the write was attempted. pxCurrentTCB points to the TCB of the + upon which the write was attempted. pxCurrentTCB points to the TCB of the task that attempted the write. */ #define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) #endif @@ -391,7 +391,9 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ #ifndef portGET_RUN_TIME_COUNTER_VALUE - #error If configGENERATE_RUN_TIME_STATS is defined then portGET_RUN_TIME_COUNTER_VALUE must also be defined. portGET_RUN_TIME_COUNTER_VALUE should evaluate to the counter value of the timer/counter peripheral used as the run time counter time base. + #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE + #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information. + #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */ #endif /* portGET_RUN_TIME_COUNTER_VALUE */ #endif /* configGENERATE_RUN_TIME_STATS */ diff --git a/Source/tasks.c b/Source/tasks.c index a39200b96..3f8d1aad0 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -1284,20 +1284,17 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) unsigned portBASE_TYPE uxQueue; unsigned long ulTotalRunTime; - /* A critical section is used because portGET_RUN_TIME_COUNTER_VALUE() - is implemented differently on different ports, so its not known if a - critical section is needed or not. */ - taskENTER_CRITICAL(); - { - ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); - } - taskEXIT_CRITICAL(); - /* This is a VERY costly function that should be used for debug only. It leaves interrupts disabled for a LONG time. */ vTaskSuspendAll(); { + #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE + portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime ); + #else + ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); + #endif + /* Run through all the lists that could potentially contain a TCB, generating a table of run timer percentages in the provided buffer. */ @@ -1603,7 +1600,13 @@ void vTaskSwitchContext( void ) #if ( configGENERATE_RUN_TIME_STATS == 1 ) { - unsigned long ulTempCounter = portGET_RUN_TIME_COUNTER_VALUE(); + unsigned long ulTempCounter; + + #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE + portALT_GET_RUN_TIME_COUNTER_VALUE( ulTempCounter ); + #else + ulTempCounter = portGET_RUN_TIME_COUNTER_VALUE(); + #endif /* Add the amount of time the task has been running to the accumulated time so far. The time the task started running was stored in