Post

Green Threads from Scratch

A compact Rust tutorial builds a cooperative stackful-task runtime, then grows it into an M:N worker scheduler; it is a useful systems-programming walkthrough, not a production runtime.

The implementation allocates guarded stacks with mmap, saves and restores ARM64 context in assembly, then adds per-worker queues, task parking, and joins. The author says the project currently targets Apple Silicon, uses fixed-size stacks, and requires explicit yielding. The post’s reported benchmark-free scope is educational; commenters also point out that its “green threads” label blurs distinctions between cooperative fibers and M:N runtimes, and that the full implementation uses Pin<Box<Task>> to enforce task address stability.

The Reddit discussion had 84 upvotes and 14 comments, including corrections on pinning, preemption, and thread-model terminology.