From: richardbarry Date: Thu, 23 Dec 2010 10:40:13 +0000 (+0000) Subject: Modify vTaskGetRunTimeStats() to ensure the current run time total is obtained from... X-Git-Tag: V6.1.1~76 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9b908b8525a8a70ce452d23b0e0a6db61420bb5d;p=freertos Modify vTaskGetRunTimeStats() to ensure the current run time total is obtained from within a critical section. This allows greater flexibility in how the run time counter value is maintained. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1181 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/tasks.c b/Source/tasks.c index 3274cbcc7..7fa375d0f 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -1282,8 +1282,17 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) void vTaskGetRunTimeStats( signed char *pcWriteBuffer ) { unsigned portBASE_TYPE uxQueue; - unsigned long ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE(); + 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. */