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.

pull/4/head
Richard Barry 14 years ago
parent f57fa8bf72
commit 95080a22f2

@ -33,9 +33,9 @@
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 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 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 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 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 by writing to Richard Barry, contact details for whom are available on the
FreeRTOS WEB site. FreeRTOS WEB site.
@ -239,17 +239,17 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
#endif #endif
#ifndef traceBLOCKING_ON_QUEUE_RECEIVE #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 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. */ task that attempted the read. */
#define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
#endif #endif
#ifndef traceBLOCKING_ON_QUEUE_SEND #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 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. */ task that attempted the write. */
#define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
#endif #endif
@ -391,7 +391,9 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
#endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */ #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
#ifndef portGET_RUN_TIME_COUNTER_VALUE #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 /* portGET_RUN_TIME_COUNTER_VALUE */
#endif /* configGENERATE_RUN_TIME_STATS */ #endif /* configGENERATE_RUN_TIME_STATS */

@ -1284,20 +1284,17 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
unsigned portBASE_TYPE uxQueue; unsigned portBASE_TYPE uxQueue;
unsigned long ulTotalRunTime; 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. /* This is a VERY costly function that should be used for debug only.
It leaves interrupts disabled for a LONG time. */ It leaves interrupts disabled for a LONG time. */
vTaskSuspendAll(); 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, /* Run through all the lists that could potentially contain a TCB,
generating a table of run timer percentages in the provided generating a table of run timer percentages in the provided
buffer. */ buffer. */
@ -1603,7 +1600,13 @@ void vTaskSwitchContext( void )
#if ( configGENERATE_RUN_TIME_STATS == 1 ) #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 /* 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 time so far. The time the task started running was stored in

Loading…
Cancel
Save