From 6e4b0c3e2f22f8a76b9a9120a5e3bb84890fb7b2 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 30 Jul 2018 14:24:03 +1000 Subject: [PATCH] freertos: Remove either one or two assertions from "fast path" of vPortCPUReleaseMutex() Saves a few cycles by only testing the count validity once, and never for the common case where the mutex was not recursively locked. --- components/freertos/portmux_impl.inc.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/freertos/portmux_impl.inc.h b/components/freertos/portmux_impl.inc.h index 29bfbfc34..07a7ce9fe 100644 --- a/components/freertos/portmux_impl.inc.h +++ b/components/freertos/portmux_impl.inc.h @@ -155,17 +155,15 @@ static inline void PORTMUX_RELEASE_MUX_FN_NAME(portMUX_TYPE *mux) { #endif assert(coreID == mux->owner); // This is a mutex we didn't lock, or it's corrupt - assert(mux->count > 0); // Indicates memory corruption - assert(mux->count < 0x100); // Indicates memory corruption mux->count--; if(mux->count == 0) { mux->owner = portMUX_FREE_VAL; - } + } else { + assert(mux->count < 0x100); // Indicates memory corruption #ifdef CONFIG_FREERTOS_PORTMUX_DEBUG_RECURSIVE - else { ets_printf("Recursive unlock: count=%d last locked %s line %d, curr %s line %d\n", mux->count, lastLockedFn, lastLockedLine, fnName, line); - } #endif + } #endif //!CONFIG_FREERTOS_UNICORE }