-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[kernel]fix scheduling exception caused by interrupt preemption in rt_schedule #10715
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
Conversation
📌 Code Review Assignment🏷️ Tag: kernelReviewers: GorrayLi ReviewSun hamburger-os lianux-mm wdfk-prog xu18838022837 Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-09-21 09:44 CST)
📝 Review Instructions
|
|
这个部分需要这样保护吗?current thread / self thread,应该总是指向当前运行的任务(而这个任务在执行rt_schedule函数),所以是当前任务的私有数据,按理说,不需要进行保护。 |
|
还是有很多地方调用 |
|
应该是isr中调用了rt_schedule,然后isr实际上这个 current_thread 是不真实的;当这个isr被另外一个高优先级的isr强制,并重新引发调度时,这个 current_thread 可能会被改成起来,从而导致两边是不一致的。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a scheduling exception caused by interrupt preemption in the rt_schedule function by moving the rt_thread_self() call inside the interrupt-disabled critical section.
- Relocates
curr_threadvariable initialization to after interrupt disable to prevent race conditions
src/scheduler_up.c
Outdated
| /* disable interrupt */ | ||
| level = rt_hw_interrupt_disable(); | ||
|
|
||
| /* using local variable to avoid unecessary function call */ |
Copilot
AI
Sep 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English: There is a typo in the comment. "unecessary" should be "unnecessary" (missing 'n'). / 中文:注释中有拼写错误。"unecessary" 应该是 "unnecessary"(缺少字母 'n')。
| /* using local variable to avoid unecessary function call */ | |
| /* using local variable to avoid unnecessary function call */ |
aa60973 to
a2baeb4
Compare
|
我测试通过。详情见论坛 |
|
如果确认修改有用的话,那看起来这个 bug fix 还挺重要的,建议尽快 cherry-pick 出来,发布新版本吧。 @BernardXiong |
下月初发,要提前测试的 |

拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up