RT-Thread / rt-thread

RT-Thread is an open source IoT real-time operating system (RTOS).
https://www.rt-thread.io
Apache License 2.0
10.21k stars 4.95k forks source link

[Feature] rtt进入临界区直接粗暴的关掉全局中断,为何不像FreeRtos那样,只关闭受操作系统管理的中断,而不关闭不受操作系统管理的中断 #9169

Open yu1999hub opened 1 month ago

yu1999hub commented 1 month ago

RT-Thread Version master Hardware Type/Architectures bsp/stm32 Develop Toolchain GCC

Describe problem solved by the proposed feature

https://github.com/RT-Thread/rt-thread/blob/master/libcpu/arm/cortex-m4/context_gcc.S#L34-L39

.global rt_hw_interrupt_disable
.type rt_hw_interrupt_disable, %function
rt_hw_interrupt_disable:
    MRS     r0, PRIMASK
    CPSID   I
    BX    

image

https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/portable/GCC/ARM_CM4F/portmacro.h#L122 https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/portable/GCC/ARM_CM4F/portmacro.h#L213-L247

    __asm volatile
    (
        "   mov %0, %1                                              \n" \
        "   msr basepri, %0                                         \n" \
        "   isb                                                     \n" \
        "   dsb                                                     \n" \
        : "=r" ( ulNewBASEPRI ) : "i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) : "memory"
    );

image

BernardXiong commented 1 month ago

这个就是要做区分的了,一些可能也会和芯片相关(是否支持中断硬件抢占,以及位数是多少等)

yu1999hub commented 1 month ago

这个就是要做区分的了,一些可能也会和芯片相关(是否支持中断硬件抢占,以及位数是多少等)

rtthead 有计划支持可选择性的关闭中断吗

logeexpluoqi commented 1 month ago

在串口数据高速收发中,921600波特率,1000Hz发送频率,serial_v2框架,非阻塞接收,一个包16-24个字节之间,经常遇到包接收不完整导致的丢包,这个会不会也是由于全局中断关闭造成的?

BernardXiong commented 1 month ago

这个就是要做区分的了,一些可能也会和芯片相关(是否支持中断硬件抢占,以及位数是多少等)

rtthead 有计划支持可选择性的关闭中断吗

可以给出方案出来,大家一起来review,讨论