Skip to content

Conversation

@wdfk-prog
Copy link
Contributor

@wdfk-prog wdfk-prog commented Sep 20, 2025

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

你的解决方案是什么 (what is your solution)

请提供验证的bsp和config (provide the config and bsp)

  • BSP:
  • .config:
  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

@github-actions
Copy link

github-actions bot commented Sep 20, 2025

📌 Code Review Assignment

🏷️ Tag: kernel

Reviewers: GorrayLi ReviewSun hamburger-os lianux-mm wdfk-prog xu18838022837

Changed Files (Click to expand)
  • src/scheduler_up.c

📊 Current Review Status (Last Updated: 2025-09-21 09:44 CST)

  • GorrayLi Pending Review
  • ReviewSun Pending Review
  • hamburger-os Pending Review
  • lianux-mm Pending Review
  • wdfk-prog Pending Review
  • xu18838022837 Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@github-actions github-actions bot added the Kernel PR has src relate code label Sep 20, 2025
@wdfk-prog
Copy link
Contributor Author

#10714

@BernardXiong
Copy link
Member

这个部分需要这样保护吗?current thread / self thread,应该总是指向当前运行的任务(而这个任务在执行rt_schedule函数),所以是当前任务的私有数据,按理说,不需要进行保护。

@Ryan-CW-Code
Copy link
Contributor

Ryan-CW-Code commented Sep 20, 2025

还是有很多地方调用rt_schedule不是在中断保护内的,比如_rt_sem_take函数内部就是在中断外调用rt_schedule
这样是有可能发生资源竞争的?
关键还是看下面的代码会不会影响别的任务私有数据

@Rbb666
Copy link
Member

Rbb666 commented Sep 20, 2025

分析了下,可能是这种场景?

image

@BernardXiong
Copy link
Member

应该是isr中调用了rt_schedule,然后isr实际上这个 current_thread 是不真实的;当这个isr被另外一个高优先级的isr强制,并重新引发调度时,这个 current_thread 可能会被改成起来,从而导致两边是不一致的。

Copy link
Contributor

Copilot AI left a 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_thread variable initialization to after interrupt disable to prevent race conditions

/* disable interrupt */
level = rt_hw_interrupt_disable();

/* using local variable to avoid unecessary function call */
Copy link

Copilot AI Sep 20, 2025

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')。

Suggested change
/* using local variable to avoid unecessary function call */
/* using local variable to avoid unnecessary function call */

Copilot uses AI. Check for mistakes.
@Rbb666
Copy link
Member

Rbb666 commented Sep 21, 2025

#8942

@wdfk-prog wdfk-prog force-pushed the schedule branch 2 times, most recently from aa60973 to a2baeb4 Compare September 21, 2025 01:43
@winfenggao
Copy link
Contributor

我测试通过。详情见论坛

@Rbb666 Rbb666 merged commit 2d375b2 into RT-Thread:master Sep 21, 2025
67 of 68 checks passed
@wdfk-prog wdfk-prog deleted the schedule branch September 22, 2025 02:11
@a1012112796
Copy link
Contributor

如果确认修改有用的话,那看起来这个 bug fix 还挺重要的,建议尽快 cherry-pick 出来,发布新版本吧。 @BernardXiong

@Rbb666
Copy link
Member

Rbb666 commented Sep 22, 2025

如果确认修改有用的话,那看起来这个 bug fix 还挺重要的,建议尽快 cherry-pick 出来,发布新版本吧。 @BernardXiong

下月初发,要提前测试的

@Rbb666 Rbb666 added this to the v5.2.2 milestone Sep 23, 2025
Rbb666 added a commit that referenced this pull request Nov 15, 2025
Rbb666 added a commit that referenced this pull request Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Kernel PR has src relate code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants