Make the thread_signal_deliverable comment match its acquire loads

未关闭 适合新手
#531 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
80/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
documentation

调研方向

阅读 src/runtime/thread.h 中 thread_signal_deliverable 上方的注释,然后阅读 src/runtime/thread.c 中使用 THREAD_FOR_EACH_ACTIVE_RELAXED 和 thread_blocked_load 的扫描。查看提交 7bfe357,了解为什么这些 acquire 加载是有意为之,并保留关于为什么陈旧读取是无害的解释。完成意味着头文件不再声称 relaxed 读取,并且如果你进行可选的重命名,该宏的每个 grep 命中都已更新,且代码树仍能构建。

由索引模型根据 Issue 内容生成。

描述

Problem

The comment above thread_signal_deliverable in src/runtime/thread.h says it "uses relaxed reads on per-thread blocked fields". The code does not: the scan in src/runtime/thread.c walks THREAD_FOR_EACH_ACTIVE_RELAXED, which loads active with memory_order_acquire, and reads each mask through thread_blocked_load, which also uses memory_order_acquire. A reader who trusts the header comment would assume weaker ordering than the code gives, and the macro name ..._RELAXED points the same wrong way.

Proposal

Drop the ordering claim from the header comment and describe it as the lock-free scan it is ("Lock-free scan of the per-thread blocked fields; ..."), keeping the existing text on why stale reads are benign. Optionally rename THREAD_FOR_EACH_ACTIVE_RELAXED to THREAD_FOR_EACH_ACTIVE_LOCKFREE, since "relaxed" there means "without thread_lock", not memory_order_relaxed. Comment-only, or a mechanical rename; no behavior change.

Alternatives

Change the loads to memory_order_relaxed to match the comment. Not proposed: the acquire loads came in with 7bfe357 ("Move shared state to C11 atomics"), and nothing here shows they are unneeded.

Origin

Found during review of #505, where cubic flagged the same wording on the new thread_signal_blocked_any comment and it was fixed there.

主要语言
C
星标
282
派生
32
平均合并
1 天 12 小时
30 天内合并 PR
17

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/elfuse 的其他 Issue

查看 sysprog21/elfuse 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。