rtel wrote on Tuesday, July 14, 2015:
I think on the Cortex-M you actually can use taskENTER_CRITICAL() and taskEXIT_CRITICAL() in an ISR - but that is one of the very few of the 35+ ports where this is the case. The reason being that on that port you cannot enter an interrupt unless the critical nesting count is 0. In other ports, although it sounds odd, it is legitimate for the FreeRTOS code (not application code!) to context switch when the critical nesting count is non-zero, and in that case using taskENTER_CRITICAL() and taskEXIT_CRITICAL() will be using the nesting count of a task (corrupting the context of a task).
There are several ‘rules of thumb’ that are stated as blanket rules, although they may not hold in all cases, because documenting each deviation is just too big a task and too confusing for end users. For example, there are rules about when an API function can and cannot be used which are stated as blanket rules that are safe in all cases, whereas the intricacies of the design means that sometimes the rules can be broken with no detrimental effect. Documenting each use case for each function is way too complex for end users, so its easier and safer to generalise rules to ensure safety in all cases.
Regards.