Skip to content

Add pt_broadcast_all() - #25

Merged
LarryRuane merged 1 commit into
masterfrom
broadcast-all
Oct 15, 2026
Merged

LarryRuane merged 1 commit into
masterfrom
broadcast-all

Conversation

@LarryRuane

Copy link
Copy Markdown
Owner

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, and pt_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 with pt_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

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
LarryRuane merged commit 04bbe58 into master Oct 15, 2026
31 checks passed
@LarryRuane
LarryRuane deleted the broadcast-all branch October 15, 2026 15:59
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.

1 participant