From: Liu Zhi Fu Date: Tue, 27 Dec 2016 04:11:07 +0000 (+0800) Subject: freertos: rework code based on review X-Git-Tag: v2.0-rc1~108^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d049fd392953d8aaf2c3cb4270aa8b401e4f016a;p=esp-idf freertos: rework code based on review --- diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 859ece2c09..d8b392d577 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -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 diff --git a/components/freertos/include/freertos/portmacro.h b/components/freertos/include/freertos/portmacro.h index 9c15eebf9a..7cae4b05b6 100644 --- a/components/freertos/include/freertos/portmacro.h +++ b/components/freertos/include/freertos/portmacro.h @@ -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 diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index 00df0df871..159d96c5b2 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -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 ) {