]> granicus.if.org Git - esp-idf/commitdiff
freertos: rework code based on review
authorLiu Zhi Fu <liuzhifu@espressif.com>
Tue, 27 Dec 2016 04:11:07 +0000 (12:11 +0800)
committerLiu Zhi Fu <liuzhifu@espressif.com>
Tue, 27 Dec 2016 04:11:07 +0000 (12:11 +0800)
components/freertos/Kconfig
components/freertos/include/freertos/portmacro.h
components/freertos/tasks.c

index 859ece2c09fbfe0b0a69f1502448867570f1e5de..d8b392d577a521b6efb8d2d5ef19d5945b54c098 100644 (file)
@@ -195,12 +195,6 @@ config FREERTOS_PORTMUX_DEBUG_RECURSIVE
         If enabled, additional debug information will be printed for recursive
         portMUX usage.
 
-config FREERTOS_INT_DISABLING_DURATION_DEBUG
-    bool "Debug interrupt disabling duration"
-    default n
-    help
-        If enabled, the longest interrupt disabling duration will be recorded.
-
 endif # FREERTOS_DEBUG_INTERNALS
 
 endmenu
index 9c15eebf9a6d4b36dc6c191f0f04b27a16aea774..7cae4b05b641a89ec3d8c202d1f3c7c47007ecd2 100644 (file)
@@ -224,9 +224,6 @@ static inline unsigned portENTER_CRITICAL_NESTED() { unsigned state = XTOS_SET_I
 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(state)     portEXIT_CRITICAL_NESTED(state)
 
 
-#define portDisableINT()       portENTER_CRITICAL_NESTED()
-#define portEnableINT(state)   portEXIT_CRITICAL_NESTED((state))
-
 /*
  * Wrapper for the Xtensa compare-and-set instruction. This subroutine will atomically compare
  * *mux to compare, and if it's the same, will set *mux to set. It will return the old value
index 00df0df8716d0af08177a48ce39240e4052c716e..159d96c5b2173a24ceea2870138f2355c49711de 100644 (file)
@@ -1041,7 +1041,7 @@ UBaseType_t x;
 
 static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode, const BaseType_t xCoreID )
 {
-        TCB_t *curTCB;
+       TCB_t *curTCB;
        BaseType_t i;
 
     /* Ensure interrupts don't access the task lists while the lists are being
@@ -1119,6 +1119,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
 
        if( xSchedulerRunning != pdFALSE )
        {
+              taskENTER_CRITICAL(&xTaskQueueMutex);
                /* Scheduler is running. If the created task is of a higher priority than an executing task
               then it should run now.
                   ToDo: This only works for the current core. If a task is scheduled on an other processor,
@@ -1135,7 +1136,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
                        {
                                taskYIELD_IF_USING_PREEMPTION();
                        }
-                       else if( xCoreID != xPortGetCoreID() ) {//TODO
+                       else if( xCoreID != xPortGetCoreID() ) {
                                taskYIELD_OTHER_CORE(xCoreID, pxNewTCB->uxPriority);
                        }
                        else
@@ -1147,6 +1148,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
                {
                        mtCOVERAGE_TEST_MARKER();
                }
+               taskEXIT_CRITICAL(&xTaskQueueMutex);
        }
        else
        {
@@ -2061,9 +2063,9 @@ void vTaskSuspendAll( void )
        http://goo.gl/wu4acr */
        unsigned state;
 
-       state = portDisableINT();
+       state = portENTER_CRITICAL_NESTED();
        ++uxSchedulerSuspended[ xPortGetCoreID() ];
-       portEnableINT(state);
+       portEXIT_CRITICAL_NESTED(state);
 }
 /*----------------------------------------------------------*/
 
@@ -3818,9 +3820,9 @@ TCB_t *pxTCB;
        TaskHandle_t xReturn;
        unsigned state;
 
-               state = portDisableINT();
+               state = portENTER_CRITICAL_NESTED();
                xReturn = pxCurrentTCB[ xPortGetCoreID() ];
-               portEnableINT(state);
+               portEXIT_CRITICAL_NESTED(state);
 
                return xReturn;
        }
@@ -3848,7 +3850,7 @@ TCB_t *pxTCB;
        BaseType_t xReturn;
        unsigned state;
 
-               state = portDisableINT();
+               state = portENTER_CRITICAL_NESTED();
                if( xSchedulerRunning == pdFALSE )
                {
                        xReturn = taskSCHEDULER_NOT_STARTED;
@@ -3864,7 +3866,7 @@ TCB_t *pxTCB;
                                xReturn = taskSCHEDULER_SUSPENDED;
                        }
                }
-               portEnableINT(state);
+               portEXIT_CRITICAL_NESTED(state);
 
                return xReturn;
        }
@@ -4403,7 +4405,7 @@ TickType_t uxReturn;
        TCB_t *curTCB;
 
                /* If xSemaphoreCreateMutex() is called before any tasks have been created
-               then xTaskGetCurrentTaskHandle() will be NULL. */
+               then pxCurrentTCB will be NULL. */
                taskENTER_CRITICAL(&xTaskQueueMutex);
                if( pxCurrentTCB[ xPortGetCoreID() ] != NULL )
                {