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

tx_thread_suspend make endless loop #233

Closed zhenbin-lin closed 1 year ago

zhenbin-lin commented 1 year ago

Describe the bug Hi developers: Today, I want to implement a delay function. such as delayMS. When I use the function tx_thread_sleep, I meet a bug. My programe only one thread, when this thread into sleep, the system will alway in PenSV_Handler that make SysTick_Handler would not be executed. So the procedure was alway loop in tx_ts_wait. That maybe can fix, I could use interrupt nesting sloving the issue. Is that possibly move tx_ts_wait out from interrupt context?

Please also mention any information which could help others to understand the problem you're facing:

zhenbin-lin commented 1 year ago

: ) sorry, my english is pool.

goldscott commented 1 year ago

Hello, you need to configure your interrupt priorities so that the systick interrupt priority is higher than the pendsv priority, as we do in tx_initialize_low_level: https://github.com/azure-rtos/threadx/blob/master/ports/cortex_m3/gnu/example_build/tx_initialize_low_level.S#L131-L132

zhenbin-lin commented 1 year ago

Hello, you need to configure your interrupt priorities so that the systick interrupt priority is higher than the pendsv priority, as we do in tx_initialize_low_level: https://github.com/azure-rtos/threadx/blob/master/ports/cortex_m3/gnu/example_build/tx_initialize_low_level.S#L131-L132

Thank you for your guidance!!! I have found the problem out my program and gained a deeper understanding of interrupts. Sorry for taking up your time.