A detailed design document for SBCL Fibers, a work-in-progress implementation of lightweight cooperative user-space threads for Steel Bank Common Lisp. Fibers address the scalability problem of OS threads (8 MB stacks, kernel context switches) and the complexity of event-driven programming by providing sequential code style with efficient cooperative scheduling. Key design aspects covered include: a full programming API (make-fiber, fiber-yield, fiber-park, fiber-join, work-stealing multi-carrier scheduling), hand-written assembly context switching that saves only callee-saved registers (6 registers on x86-64 SysV), zero-allocation switch paths, stack pooling via madvise(MADV_DONTNEED), correct handling of Common Lisp's dynamic variable bindings (TLS overlay arrays), GC integration with conservative control stack scanning, a Chase-Lev lock-free work-stealing deque for multi-core utilization, epoll/kqueue I/O multiplexing, and deadline scheduling with a binary min-heap. Platform support spans x86-64, ARM64, ARM32, PPC64, PPC32, and RISC-V.
Table of contents
Table of Contents #1. Introduction #2. Programming API #3. Architecture Overview #4. Context Switching #5. Stack Management #6. Dynamic Variable Bindings (TLS) #7. Garbage Collector Integration #8. Scheduler Design #9. Work Stealing #10. I/O Multiplexing #11. Deadline Scheduling #12. Fiber Death and Cleanup #13. Integration with SBCL #14. Performance #15. Platform Support #Appendix A: Using Hunchentoot with Fibers #Sort: