CPU loops in while(1) in single threaded environment #76240
Unanswered
vikash-singh-rawat
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Dear Community Members,
CPU keep looping in while(1) with irq_lock() after calling and returning from the main() function in case single threaded environment (CONFIG_MULTITHREADING=n). However CPU will be in WFI in case of multithreading in idle thread.
https://github.com/zephyrproject-rtos/zephyr/blob/main/kernel/init.c#L694C1-L702C4
https://github.com/zephyrproject-rtos/zephyr/blob/main/arch/riscv/core/thread.c#L223C1-L227C1
It keeps the CPU busy without doing any significant task. Moreover CPU doesn’t serve any external interrupt as irq_lock() is called before while(1) which disable the external interrupt (in case of RISC V).
Is there any specific reason for it ?
Can we keep the CPU in WFI with irq_unlock() after calling main() for single threaded environment ?
Beta Was this translation helpful? Give feedback.
All reactions