eclipse-threadx / threadx

Eclipse ThreadX is an advanced real-time operating system (RTOS) designed specifically for deeply embedded applications.
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/threadx/index.md
MIT License
2.87k stars 782 forks source link

Can TX_DISABLE/TX_RESTORE be called in interrupt handler in smp system? #219

Open carll00226 opened 1 year ago

carll00226 commented 1 year ago

Hi, scott: I'm running threadx in a two-core smp sytem of a arm 32-bit platform, and get dead lock while two cores are all in already_in_list1 of tx_thread_smp_protect.S. One of the core is in interrupt handler and called TX_DISABLE while the IRQs are disabled. I don't know if the tx_thread_smp_wait_list should be changed relied on the SGI, but as the IRQs are disabled, the core can't generate SGI to modify the tx_thread_smp_wait_list. I want to know if TX_DISABLE/TX_RESTORE can be called in isr while IRQs are disabled? Because if the core cannot get locked in tx_thread_smp_protect, it will execute MSR CPSR_c, r0 to restore CPSR to generate SGI. And what about other APIs such as tx_semaphore_get which will call TX_DISABLE in it's context? Thanks.

goldscott commented 1 year ago

Hi @carll00226,

This deadlock is a known issue. It was fixed in the Armv8-A ports but not yet in the Armv7-A ports. It will be fixed in the next release.

TX_DISABLE and TX_RESTORE can be called in ISRs. If interrupts are disabled, TX_DISABLE and TX_RESTORE don't actually do anything (the interrupt state is saved and restored, respectively, and since interrupts are disabled, nothing really happens).