May 2020
Intermediate to advanced
496 pages
13h 54m
English
While mutexes help to provide protection against some priority inversion, we can take an additional step to make sure the mutex doesn't become an unnecessary crutch. The section of code that's protected by the mutex is referred to as a critical section:
if(xSemaphoreTake(mutexPtr, 200/portTICK_PERIOD_MS) == pdPASS){ //critical section is here //KEEP THIS AS SHORT AS POSSIBLE xSemaphoreGive(mutexPtr);}
Taking steps to ensure this critical section is as short as possible will help in a few areas: