Make the thread_signal_deliverable comment match its acquire loads

Open Beginner friendly
#531 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
80/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
documentation

Research direction

Read the comment above thread_signal_deliverable in src/runtime/thread.h, then the scan in src/runtime/thread.c that uses THREAD_FOR_EACH_ACTIVE_RELAXED and thread_blocked_load. Check commit 7bfe357 for why the acquire loads are intentional, and keep the explanation of why stale reads are benign. Done means the header no longer claims relaxed reads, and if you take the optional rename, every grep hit for the macro is updated and the tree still builds.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C
Stars
287
Forks
33
Avg merge
2d 17h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/elfuse

All issues in sysprog21/elfuse

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.