Repository navigation
README: scaling notes, and an accurate comparison with Dunkels' - #27
Merged
Merged
Conversation
The broadcast-cost paragraph framed the cost as small because microcontrollers have few protothreads. The real point is how many waiters share one channel, which holds on any hardware. The PT_NWAIT entry only covered shrinking the table. With many more waiters than buckets each wakeup walks a long list (measured: 67 us per handoff with 1M waiters and 1024 buckets, 117 ns with 2^20), so say to raise it. Link Dunkels' protothreads site, which is friendlier and links the paper, instead of the PDF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
Wait channels and nesting are the two main differences from Dunkels' protothreads. Put the scheduler first, since nesting's difference is explained in terms of it, and say that a blocked thread takes no CPU time however long it waits. Add a TODO entry for growing the wait table at runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
Dunkels' PT_SPAWN() nests blocking functions the same way pt_call() does: the parent re-calls the child on resume, at any depth, with arguments. The difference is when the chain is re-entered, which is the scheduler's doing, so say that in the scheduler bullet and drop the separate nesting bullet. Nesting works with Dunkels' switch-based version too, so only blocking inside a switch needs labels-as-values. Likewise, the bytes per thread over Dunkels' buy the wait lists, not nesting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
Dunkels' PT_WAIT_UNTIL() takes the condition as an argument, and a reader may ask why pt_wait() doesn't. A bare wait can sit deep inside nested control flow, with the code re-evaluating everything from the top after it wakes, which is how some UTS kernel code was written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
"Leaves scheduling to the application" didn't say what that means. His library has no list of threads; the application's loop calls each one in turn, which acts like a single run list holding every thread, blocked or not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs
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.
Five doc commits:
PT_NWAITentry says to raise it for large numbers of protothreads. With 1M waiters and the default 1024 buckets, a handoff took 67 us, against 117 ns with 2^20 buckets.PT_SPAWN()nests the same way. Also fixes two related claims: only blocking inside aswitchneeds labels-as-values, and the bytes per thread over Dunkels' buy the wait lists, not nesting.pt_wait()takes no condition, unlike Dunkels'PT_WAIT_UNTIL().Also adds a TODO entry for growing the wait table at runtime.
The timer heap is a separate branch on top of this one, and will be its own PR once this is merged.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SR7v9BVsFrHiEhQBSqZmAs