About portSET_INTERRUPT_MASK_FROM_ISR()

Hello everyone,

I’m currently learning FreeRTOS on ARM Cortex-M3 and came across the macro portSET_INTERRUPT_MASK_FROM_ISR(), which is the ISR version of the API for entering a critical section. The task-level critical-section API uses the uxCriticalNesting variable to keep track of the nesting level, whereas the ISR version uses a “snapshot” (save-and-restore) approach instead.

I’m curious about the rationale behind this design. Why can’t the ISR version also use uxCriticalNesting to track nesting and implement critical-section entry/exit in the same way as the task-level version?

Thanks in advance for any insights.