Repository navigation
Add pt_broadcast_all() - #25
Merged
Merged
Conversation
Make every waiting protothread ready, whatever its channel. Every wait re-tests its condition, so this is always safe, and calling it periodically turns a lost wakeup from a hang into a delay. Each wait bucket is emptied in its own critical section, so interrupt latency stays bounded as with pt_broadcast(). The README also describes using it for an orderly shutdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
LarryRuane
force-pushed
the
broadcast-all
branch
from
October 15, 2026 15:52
4fec415 to
9ebe75a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pt_broadcast_all(s)makes every waiting protothread ready, whatever channel it's waiting on. Every wait re-tests its condition in a loop, including the ones inside the semaphore, lock, timer, queue, andpt_join()code, so this is always safe. Calling it periodically turns a lost wakeup from a hang into a delay. It can also be part of an orderly shutdown, which the README now describes.Each wait bucket is emptied in its own critical section, so with
PT_CRITICAL_*defined, interrupt latency stays bounded as withpt_broadcast(). Empty buckets are skipped without entering one.The new test sets up a lost wakeup alongside threads blocked on a semaphore, a join, and a sleep. It checks that the lost wakeup is recovered, that the others go back to waiting, that the ready function is called once, and that the real events still complete them afterwards.
The lost-wakeup detector from the TODO.md sweep item is still left to do.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs