Make the thread_signal_deliverable comment match its acquire loads

Aperta Adatta ai principianti
#531 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
80/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
documentation

Direzione di ricerca

Leggi il commento sopra thread_signal_deliverable in src/runtime/thread.h, poi la scansione in src/runtime/thread.c che usa THREAD_FOR_EACH_ACTIVE_RELAXED e thread_blocked_load. Controlla il commit 7bfe357 per capire perché i caricamenti acquire sono intenzionali, e mantieni la spiegazione del perché le letture obsolete sono innocue. Fatto significa che l'header non dichiara più letture relaxed, e se fai la rinomina opzionale, ogni occorrenza grep per la macro viene aggiornata e l'albero continua a compilare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C
Stelle
282
Fork
32
Merge medio
1g 12h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sysprog21/elfuse

Tutte le issue di sysprog21/elfuse

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.