Quellcode durchsuchen

freertos: rework code based on review

Liu Zhi Fu vor 9 Jahren
Ursprung
Commit
d049fd3929

+ 0 - 6
components/freertos/Kconfig

@@ -195,12 +195,6 @@ config FREERTOS_PORTMUX_DEBUG_RECURSIVE
         If enabled, additional debug information will be printed for recursive
         If enabled, additional debug information will be printed for recursive
         portMUX usage.
         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
 endif # FREERTOS_DEBUG_INTERNALS
 
 
 endmenu
 endmenu

+ 0 - 3
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 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
  * 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
  * *mux to compare, and if it's the same, will set *mux to set. It will return the old value

+ 11 - 9
components/freertos/tasks.c

@@ -1041,7 +1041,7 @@ UBaseType_t x;
 
 
 static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode, const BaseType_t xCoreID )
 static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode, const BaseType_t xCoreID )
 {
 {
-        TCB_t *curTCB;
+	TCB_t *curTCB;
 	BaseType_t i;
 	BaseType_t i;
 
 
     /* Ensure interrupts don't access the task lists while the lists are being
     /* 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 )
 	if( xSchedulerRunning != pdFALSE )
 	{
 	{
+	       taskENTER_CRITICAL(&xTaskQueueMutex);
 		/* Scheduler is running. If the created task is of a higher priority than an executing task
 		/* Scheduler is running. If the created task is of a higher priority than an executing task
 	       then it should run now.
 	       then it should run now.
 		   ToDo: This only works for the current core. If a task is scheduled on an other processor,
 		   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();
 				taskYIELD_IF_USING_PREEMPTION();
 			}
 			}
-			else if( xCoreID != xPortGetCoreID() ) {//TODO
+			else if( xCoreID != xPortGetCoreID() ) {
 				taskYIELD_OTHER_CORE(xCoreID, pxNewTCB->uxPriority);
 				taskYIELD_OTHER_CORE(xCoreID, pxNewTCB->uxPriority);
 			}
 			}
 			else
 			else
@@ -1147,6 +1148,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
 		{
 		{
 			mtCOVERAGE_TEST_MARKER();
 			mtCOVERAGE_TEST_MARKER();
 		}
 		}
+	        taskEXIT_CRITICAL(&xTaskQueueMutex);
 	}
 	}
 	else
 	else
 	{
 	{
@@ -2061,9 +2063,9 @@ void vTaskSuspendAll( void )
 	http://goo.gl/wu4acr */
 	http://goo.gl/wu4acr */
 	unsigned state;
 	unsigned state;
 
 
-	state = portDisableINT();
+	state = portENTER_CRITICAL_NESTED();
 	++uxSchedulerSuspended[ xPortGetCoreID() ];
 	++uxSchedulerSuspended[ xPortGetCoreID() ];
-	portEnableINT(state);
+	portEXIT_CRITICAL_NESTED(state);
 }
 }
 /*----------------------------------------------------------*/
 /*----------------------------------------------------------*/
 
 
@@ -3818,9 +3820,9 @@ TCB_t *pxTCB;
 	TaskHandle_t xReturn;
 	TaskHandle_t xReturn;
 	unsigned state;
 	unsigned state;
 
 
-		state = portDisableINT();
+		state = portENTER_CRITICAL_NESTED();
 		xReturn = pxCurrentTCB[ xPortGetCoreID() ];
 		xReturn = pxCurrentTCB[ xPortGetCoreID() ];
-		portEnableINT(state);
+		portEXIT_CRITICAL_NESTED(state);
 
 
 		return xReturn;
 		return xReturn;
 	}
 	}
@@ -3848,7 +3850,7 @@ TCB_t *pxTCB;
 	BaseType_t xReturn;
 	BaseType_t xReturn;
 	unsigned state;
 	unsigned state;
 
 
-		state = portDisableINT();
+		state = portENTER_CRITICAL_NESTED();
 		if( xSchedulerRunning == pdFALSE )
 		if( xSchedulerRunning == pdFALSE )
 		{
 		{
 			xReturn = taskSCHEDULER_NOT_STARTED;
 			xReturn = taskSCHEDULER_NOT_STARTED;
@@ -3864,7 +3866,7 @@ TCB_t *pxTCB;
 				xReturn = taskSCHEDULER_SUSPENDED;
 				xReturn = taskSCHEDULER_SUSPENDED;
 			}
 			}
 		}
 		}
-		portEnableINT(state);
+		portEXIT_CRITICAL_NESTED(state);
 
 
 		return xReturn;
 		return xReturn;
 	}
 	}
@@ -4403,7 +4405,7 @@ TickType_t uxReturn;
 	TCB_t *curTCB;
 	TCB_t *curTCB;
 
 
 		/* If xSemaphoreCreateMutex() is called before any tasks have been created
 		/* If xSemaphoreCreateMutex() is called before any tasks have been created
-		then xTaskGetCurrentTaskHandle() will be NULL. */
+		then pxCurrentTCB will be NULL. */
 		taskENTER_CRITICAL(&xTaskQueueMutex);
 		taskENTER_CRITICAL(&xTaskQueueMutex);
 		if( pxCurrentTCB[ xPortGetCoreID() ] != NULL )
 		if( pxCurrentTCB[ xPortGetCoreID() ] != NULL )
 		{
 		{