]> granicus.if.org Git - esp-idf/commitdiff
Add static initializers for muxes, add mutex init to vPortCPUAcquireMutex
authorJeroen Domburg <git@j0h.nl>
Mon, 22 Aug 2016 09:36:32 +0000 (17:36 +0800)
committerJeroen Domburg <git@j0h.nl>
Mon, 22 Aug 2016 09:36:32 +0000 (17:36 +0800)
components/freertos/event_groups.c
components/freertos/heap_regions.c
components/freertos/include/freertos/portmacro.h
components/freertos/port.c
components/freertos/queue.c
components/freertos/tasks.c
components/freertos/timers.c

index 1aa95e0841f4dfb15e17401615a955f78383a875..0eafab10a5bb4263530c8421d42d65fc40a0826c 100644 (file)
@@ -123,7 +123,7 @@ typedef struct xEventGroupDefinition
 
 
 /* Again: one mux for all events. Maybe this can be made more granular. ToDo: look into that. -JD */
-static portMUX_TYPE xEventGroupMux;
+static portMUX_TYPE xEventGroupMux = portMUX_INITIALIZER_UNLOCKED;
 static BaseType_t xMuxInitialized = pdFALSE;
 
 
index d1ab6240b6fb562698c4559b7dd51a16f8e47488..491a1fe6eb6ab19260daf1aaab437fd74b0a3a5c 100644 (file)
@@ -155,7 +155,7 @@ typedef struct A_BLOCK_LINK
 } BlockLink_t;
 
 //Mux to protect the memory status data
-static portMUX_TYPE xMallocMutex;
+static portMUX_TYPE xMallocMutex = portMUX_INITIALIZER_UNLOCKED;
 
 /*-----------------------------------------------------------*/
 
index b659a8271ef2beedde39451ed4a9974c41b70e6d..c698cb8cb3e1f52ed392ec0446dd426997862fe7 100644 (file)
@@ -147,6 +147,13 @@ typedef struct {
 #define portMUX_VAL_MASK               0x000000FF
 #define portMUX_VAL_SHIFT              0
 
+//Keep this in sync with the portMUX_TYPE struct definition
+#ifdef portMUX_DEBUG
+#define portMUX_INITIALIZER_UNLOCKED { portMUX_MAGIC_VAL|portMUX_FREE_VAL }
+#else
+#define portMUX_INITIALIZER_UNLOCKED { portMUX_MAGIC_VAL|portMUX_FREE_VAL, "(never locked)", -1 }
+#endif
+
 /* Critical section management. NW-TODO: replace XTOS_SET_INTLEVEL with more efficient version, if any? */
 // These cannot be nested. They should be used with a lot of care and cannot be called from interrupt level.
 #define portDISABLE_INTERRUPTS()      do { XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); portbenchmarkINTERRUPT_DISABLE(); } while (0)
index fd7760e014157a1f5a40965936b92f155d5d2169..0be29c19073eaaff67cf778587dcef316bb628e5 100644 (file)
@@ -297,7 +297,8 @@ void vPortCPUAcquireMutex(portMUX_TYPE *mux) {
 #ifdef portMUX_DEBUG
        uint32_t cnt=(1<<16);
        if ( (mux->mux & portMUX_MAGIC_MASK) != portMUX_MAGIC_VAL ) {
-               ets_printf("ERROR: vPortCPUAcquireMutex: mux %p is uninitialized (0x%X)!\n", mux, mux->mux);
+               ets_printf("ERROR: vPortCPUAcquireMutex: mux %p is uninitialized (0x%X)! Called from %s line %d.\n", mux, mux->mux, fnName, line);
+               asm("break.n 1");
                mux->mux=portMUX_FREE_VAL;
        }
 #endif
index 337352fca832af2668c2a6d67106cc1ab8bb4d6f..92e182a62094a4393d90028e3eb752b7a978aca5 100644 (file)
@@ -460,6 +460,8 @@ int8_t *pcAllocatedBuffer;
                        vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
                        vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );
 
+                       vPortCPUInitializeMutex(&pxNewQueue->mux);
+
                        traceCREATE_MUTEX( pxNewQueue );
 
                        /* Start with the semaphore in the expected state. */
index d747708eb0059e3ee30de7c499409961b457cf3c..f0e4fb120aa37403fa49489a321a07c237c6840f 100644 (file)
@@ -273,8 +273,8 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended[ portNUM_PROCES
 PRIVILEGED_DATA static portBASE_TYPE xMutexesInitialised = pdFALSE;
 /* For now, we use just one mux for all the critical sections. ToDo: give evrything a bit more granularity;
   that could improve performance by not needlessly spinning in spinlocks for unrelated resources. */
-PRIVILEGED_DATA static portMUX_TYPE xTaskQueueMutex;
-PRIVILEGED_DATA static portMUX_TYPE xTickCountMutex;
+PRIVILEGED_DATA static portMUX_TYPE xTaskQueueMutex = portMUX_INITIALIZER_UNLOCKED;
+PRIVILEGED_DATA static portMUX_TYPE xTickCountMutex = portMUX_INITIALIZER_UNLOCKED;
 
 #if ( configGENERATE_RUN_TIME_STATS == 1 )
 
index 7c0ba5bd9ad76062d270a863608bcab1c7a7acbf..92e4bf94ad5c9fead50af9d706dfd4576224c406 100644 (file)
@@ -170,7 +170,7 @@ PRIVILEGED_DATA static List_t *pxOverflowTimerList;
 PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL;
 
 /* Mux. We use a single mux for all the timers for now. ToDo: maybe increase granularity here? */
-PRIVILEGED_DATA portMUX_TYPE xTimerMux;
+PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
 
 #if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 )