New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CONFIG_MULTITHREADING=n
builds call main()
with interrupts locked
#8393
Comments
The root cause here is that where the default Zephyr thread startup sets the lock state to a known value inside arch code, where we are at the end of _Cstart() is unspecified. We never took a lock, so we can't release it. There needs to be an arch hook for "enable interrupts unconditionally", either a new API call or a special key value that can be passed to irq_unlock(). |
Raising priority because this cannot be easily worked around on the application code in a way that is cross-arch and clean. |
@agross-linaro @andyross I also notice that even when enabling interrupts I see behavior that is not explained by my code. Could it be that the ISR wrapper in https://github.com/zephyrproject-rtos/zephyr/blob/master/arch/arm/core/isr_wrapper.S#L42 also needs conditional compilation based on |
If no multithreading then yeah this shouldn't be setting the context switch. |
@agross-linaro I've disabled |
Due to an issue described here: zephyrproject-rtos/zephyr#8393 interrupts are not enabled when multithreading is disabled. Enable interrupts to allow the serial recovery mode UART to receive characters. Note: This commit must be reverted once the issue is addressed. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Due to an issue described here: zephyrproject-rtos/zephyr#8393 interrupts are not enabled when multithreading is disabled. Enable interrupts to allow the serial recovery mode UART to receive characters. Note: This commit must be reverted once the issue is addressed. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Due to an issue described here: zephyrproject-rtos/zephyr#8393 interrupts are not enabled when multithreading is disabled. Enable interrupts to allow the serial recovery mode UART to receive characters. Note: This commit must be reverted once the issue is addressed. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Due to an issue described here: zephyrproject-rtos/zephyr#8393 interrupts are not enabled when multithreading is disabled. Enable interrupts to allow the serial recovery mode UART to receive characters. Note: This commit must be reverted once the issue is addressed. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Due to an issue described here: zephyrproject-rtos/zephyr#8393 interrupts are not enabled when multithreading is disabled. Enable interrupts to allow the serial recovery mode UART to receive characters. Note: This commit must be reverted once the issue is addressed. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Added an MCUboot issue to be resolved once this one is closed: mcu-tools/mcuboot#302 |
Due to an issue described here: zephyrproject-rtos/zephyr#8393 interrupts are not enabled when multithreading is disabled. Enable interrupts to allow the serial recovery mode UART to receive characters. Note: This commit must be reverted once the issue is addressed. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Drop priority as there's an active workaround and it's not blocking work. It remains a real bug and needs a fix for 1.13. |
@andyross ping |
Some applications have a use case for a tiny MULTITHREADING=n build (which lacks most of the kernel) but still want special-purpose drivers in that mode that might need to handle interupts. This creates a chicken and egg problem, as arch code (for obvious reasons) runs _Cstart() with interrupts disabled, and enables them only on switching into a newly created thread context. Zephyr does not have a "turn interrupts on now, please" API at the architecture level. So this creates one as an arch-specific wrapper around _arch_irq_unlock(). It's implemented as an optional macro the arch can define to enable this behavior, falling back to the previous scheme (and printing a helpful message) if it doesn't find it defined. Only ARM and x86 are enabled in this patch. Fixes zephyrproject-rtos#8393 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
@carlescufi would be great to specify why all of this is needed, are we still going after the few kilobytes from the kernel or is there some other rationale for having this supported? |
The idea is to be able to use Zephyr as an almost "bare-metal" development platform. Threads and threading can be expensive in RAM and ROM footprint, but Zephyr provides a lot of value beyond its RTOS underpinnings:
I personally believe that maintaining the possibility of using Zephyr in this way it's added value at a (relative) low cost for the project, so I would be very much in favor of formally defining the requirements and limitations and then officially supporting this "feature". |
There are some additional benchmarks here. |
Some applications have a use case for a tiny MULTITHREADING=n build (which lacks most of the kernel) but still want special-purpose drivers in that mode that might need to handle interupts. This creates a chicken and egg problem, as arch code (for obvious reasons) runs _Cstart() with interrupts disabled, and enables them only on switching into a newly created thread context. Zephyr does not have a "turn interrupts on now, please" API at the architecture level. So this creates one as an arch-specific wrapper around _arch_irq_unlock(). It's implemented as an optional macro the arch can define to enable this behavior, falling back to the previous scheme (and printing a helpful message) if it doesn't find it defined. Only ARM and x86 are enabled in this patch. Fixes zephyrproject-rtos#8393 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
single threading is scheduled for deprecation, so lower priority. |
Why keep this open? It's unlikely that the decision will change, and if it does part of the task will be to identify all the things that need to work, in which case this issue will be rediscovered. Keeping it open affects the low bug count which can now impact release. I'd rather close all these issues and move on. Maybe discuss next triage. |
clearing assignee as this feature is being deprecated, we can talk about this next and discuss if someone will step up and own this and if those issues will be assigned to them. The bug is open, but the code is still in the tree, even with deprecation. Deprecated code does not mean we stop fixing bugs. |
@ioannisg re our discussion earlier today. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
reopening as this still applies |
@carlescufi you reopened this, however, I am not sure if this still applies. CONFIG_MULTITHREADING=n is only maintained on Cortex-M, for now, and I can confirm that in Cortex-M this is not an issue. |
I agree, as long as you confirm that this is not an issue with Cortex-M then we can close this @ioannisg |
@carlescufi ^^ |
Thanks for confirming @ioannisg. Closing this now. |
For consistency with multithreaded builds,
main()
should be called with interrupts unlocked and ready to go.The text was updated successfully, but these errors were encountered: