Lightweight thread library
Allocate stacks using mmap()
rename task->orig_stack to task->stack



You can also use your local clone with git send-email.


This is a small C library which implements a cooperative multithreading, user level threading system and event loop. What this means is that, using this library, an application may have multiple threads of execution, without requesting new OS-level threads. These threads are not preempted by each other, instead they hand off control when they have no work to do. This sort of system is ideal for an I/O bound application. To get an idea for what is possible, see the examples directory.


  • Threads may explicitly "yield" control and be scheduled later
  • Threads may add file descriptors to the event loop, so they are woken when the file descriptors have data for read / write / error.
  • Threads may set timeouts, or sleep.

This library is part of the "sc-" (Stephen's C) family of libraries. Each library is intended to be small and modular, built using the Meson build system for easy dependency management. For full examples of the use of this and other "sc-" libraries, see the sc-examples repository.


Run the following to create a build directory:

meson build

You may then compile (or re-compile) with:

ninja -C build

When you would like to commit your changes, please ensure that you have pre-commit hooks installed, so that automated checks can run on your code:

pre-commit install