RTOS Interrupts - Protecting Shared Resources Using Disabled Interrupts

RTOS Interrupts - Protecting Shared Resources Using Disabled Interrupts

overview

When there is access to shared resources between interrupts and interrupts, interrupts and tasks, the shared resources can be protected by turning off interrupts.

As mentioned above , in ESP-IDF, the implementation principle of the critical section is to disable interrupts. Although the previous section described the method of reducing the side effects of the critical section (affecting all interrupt responses of the device), sometimes we can also achieve smaller side effects through other operations that disable interrupts. This section describes some other ways to turn off interrupts.

Disable interrupts for the current CPU core

As a dual-core device, ESP32 has the function of closing the interrupt of the current CPU core:

taskDISABLE_INTERRUPTS();//关闭当前核心中断响应
taskENABLE_INTERRUPTS()//打开中断响应

Guess you like

Origin blog.csdn.net/wangyx1234/article/details/128267792