Hi, On Wed, Sep 8, 2021 at 10:23 AM Katsuhiro Suzuki <katsuhiro@...> wrote:
I have question about newer version of context switching (CONFIG_USE_SWITCH=y).
Does RISC-V support USE_SWITCH?
Currently, No. I'm trying to add a support for CONFIG_USE_SWITCH=y case.
Newer switching sets NEW thread handle into _current_cpu.current BEFORE calling arch_switch(). This implementation will face a problem in RISC-V environment if thread calls do_swap() explicitly and switch to thread B (use FPU) from thread A (not use FPU) because...
AFAICS, even with v1.11, we are setting `_current` to `new_thread` in `_Swap()` before calling `_arch_switch()`. What version are you referring to as "older"?
Sorry for confusing. Older means CONFIG_USE_SWITCH=n. Does not means Zephyr's version.
Why do you `use _current_cpu` at all? `_arch_switch()` or `arch_switch()` on the main branch takes both new and old thread handles.
Because to keep consistency for another context switching (by preemption) and other interrupts. Only _current_cpu.current is available when an interrupt occurred.