Interrupts and Critical Section (OSEK/VDX)

What is the difference between DisableAllInterrupts and SuspendAllInterrupts?

There is no such FreeRTOS API. Which other library do you use ?
However, if you mean vTaskSuspend/ResumeAll vs. taskENTER/EXIT_CRITICAL(_FROM_ISR ) the 1st variant can be used to implement critical sections at task level by disable/enable the scheduler, but keeping ISRs enabled, which is usually desired.
It’s preferred way when protecting code/data used only by tasks and not by ISRs.
The 2nd variant can be used for global critical sections including ISR code/data because it disables all interrupts (covered by FreeRTOS) while inside a critical section.

1 Like

One other key difference is that the ENTER/EXIT_CRITICAL operations are very fast, just a couple of machine instructions long, while the TaskSuspend/ResumeAll can be somewhat heavy weight, so for a very short piece of code, like updating/reading a small structure atomically, the CRITICAL operations might be preferred even if they do affect interrupts.

1 Like