From 7d1cc21a1dde9236a63083fa828ae7ff66d122bb Mon Sep 17 00:00:00 2001 From: RichardBarry Date: Wed, 11 Mar 2009 10:55:41 +0000 Subject: Some optimisations added. git-svn-id: https://freertos.svn.sourceforge.net/svnroot/freertos/trunk@704 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/tasks.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/Source/tasks.c b/Source/tasks.c index eb63bdef..0a363ecc 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -1014,9 +1014,9 @@ void vTaskEndScheduler( void ) void vTaskSuspendAll( void ) { - portENTER_CRITICAL(); - ++uxSchedulerSuspended; - portEXIT_CRITICAL(); + /* A critical section is not required as the variable is of type + portBASE_TYPE. */ + ++uxSchedulerSuspended; } /*----------------------------------------------------------*/ @@ -1119,13 +1119,9 @@ portTickType xTicks; unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) { -unsigned portBASE_TYPE uxNumberOfTasks; - - taskENTER_CRITICAL(); - uxNumberOfTasks = uxCurrentNumberOfTasks; - taskEXIT_CRITICAL(); - - return uxNumberOfTasks; + /* A critical section is not required because the variables are of type + portBASE_TYPE. */ + return uxCurrentNumberOfTasks; } /*-----------------------------------------------------------*/ @@ -1351,7 +1347,8 @@ void vTaskIncrementTick( void ) xTCB = ( tskTCB * ) xTask; } - /* Save the hook function in the TCB. */ + /* Save the hook function in the TCB. A critical section is required as + the value can be accessed from an interrupt. */ portENTER_CRITICAL(); xTCB->pxTaskTag = pxTagValue; portEXIT_CRITICAL(); @@ -1899,15 +1896,10 @@ tskTCB *pxNewTCB; xTaskHandle xTaskGetCurrentTaskHandle( void ) { - xTaskHandle xReturn; - - portENTER_CRITICAL(); - { - xReturn = ( xTaskHandle ) pxCurrentTCB; - } - portEXIT_CRITICAL(); - - return xReturn; + /* A critical section is not required as this is not called from + an interrupt and the current TCB will always be the same for any + individual execution thread. */ + return pxCurrentTCB; } #endif -- cgit v1.2.3