How rwtesh/thread_library works
This is a small cooperative user-level thread library. An application initializes the library, creates threads, and starts the scheduler; thread functions explicitly yield or exit. The scheduler switches ucontext contexts, selects work from a FIFO ready queue, requeues yielded threads, and frees terminated threads. The graph reflects the sampled implementation and README capabilities; ucontext is shown as an external runtime dependency.
Components 7
Public API
- Thread API
include/threads.h
Thread Lifecycle
- Thread Lifecycle
src/threads.c - Thread Records
src/thread.h
Cooperative Scheduling
- Scheduler
src/scheduler.c
Runtime Support
- FIFO Ready Queue
src/queue.c - ucontext Runtime
Other components
- Application
Connections 7
- Application → Thread API: calls
- Thread Lifecycle → Scheduler: starts scheduling
- Thread Lifecycle → Thread Records: creates records
- Thread Lifecycle → ucontext Runtime: switches contexts
- Scheduler → FIFO Ready Queue: dispatches queue
- Scheduler → ucontext Runtime: switches contexts
- Scheduler → Thread Records: tracks state