The iMutex uint8_t is modified without using atomics or taking a lock, so it can very much end up in a bad state if accessed from multiple CPU cores. (Maybe also still possibly problematic with multiple preemptively scheduled RTOS threads, in particular when an IRQ triggers a thread change, e.g. using taskYIELD_FROM_ISR in FreeRTOS)