Skip to content

Conversation

@zmshahaha
Copy link
Contributor

@zmshahaha zmshahaha commented Mar 28, 2024

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

[

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

之前的workqueue/timer有如下问题

  1. rt_workqueue_cancel_work在对work的timer执行停止操作未判断返回值。若在timer线程执行work的timer的回调函数时,另一线程调用rt_workqueue_cancel_work停止该work的timer,此时timer_stop应失败,但之前未考虑此情况,仍按cancel_work成功的逻辑进行
  2. 在timer线程执行某timer的timer_out函数时,若另一线程对该timer执行rt_timer_start,应让其执行失败。否则会出现数据混乱。若该线程执行了timer_start又立即让其stop,就会触发ASSERT
  3. 之前rt_workqueue_submit_work中调用了rt_timer_start,但该函数不在spinlock的保护范围中,与其他对workqueue数据结构修改操作不是原子的。若执行了spinlock保护范围内操作后调度出去,可能出现数据不一致情况。

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

1.rt_workqueue_cancel_work中判断rt_timer_stop是否成功
2. 增加timer的执行状态RT_TIMER_FLAG_PROCESSING。该状态下使timer_start执行失败

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

rk3588

  • 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

@zmshahaha zmshahaha force-pushed the wq branch 2 times, most recently from b67fc25 to c16052c Compare March 28, 2024 08:08
@zmshahaha zmshahaha marked this pull request as draft March 28, 2024 08:49
@zmshahaha zmshahaha marked this pull request as ready for review March 28, 2024 11:12
@zmshahaha
Copy link
Contributor Author

@polarvid 现在可以了

@zmshahaha zmshahaha marked this pull request as draft March 29, 2024 08:03
@zmshahaha zmshahaha force-pushed the wq branch 2 times, most recently from 0684a49 to c040935 Compare April 1, 2024 06:50
@zmshahaha zmshahaha marked this pull request as ready for review April 1, 2024 06:51
@mysterywolf mysterywolf merged commit 6ad0b2b into RT-Thread:master Apr 16, 2024
@zmshahaha zmshahaha deleted the wq branch May 10, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants