Skip to content

ziyi-yan/green-threads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Green Threads

The 200-line implementation of green threads from this tutorial with comments about the details I learned.

TODO

  • Growable stacks
  • x86-64 psABI stack layout and calling convention
    • Q: how %rsp register works in stack construction in spawn()
      • when ret
      • when to move to next byte
    • A: Princeton COS217 slide on "Assembly Langauge: Function Calls"
  • why #[inline(never)] for switch()?
    • It's for stack alignment.

      In the perspective of one task, call switch sub %rsp for storing the %rip when suspended. When it's resumed, ret add %rsp back to the original aligned address.

Releases

No releases published

Packages

No packages published

Languages