this project is something i have been Procastinating the work on for a long time but now is the time, gthreads as "green-threads" is deterministic user-space threading runtime in C, designed to demonstrate OS/runtime knowleadge into something paractical notations covered "or may be covered" context switching, stack management, scheduling, synchronization, and reproducible concurrency debugging.
to build a production-style green-thread library with:
- User-space threads and cooperative/preemptive scheduling (configurable)
- Synchronization primitives (mutex, semaphore, condition variable)
- Linux event-loop integration (
epoll) - Deterministic replay + schedule fuzzing for race reproduction
after researching alot of refrences i found out most green-thread projects stop at Round Robin scheduling. So gthreads adds a trace/replay subsystem that records scheduling and synchronization events and replays them deterministically to reproduce nondeterministic bugs.
- Kernel-level threading
- Windows/macOS portability (Linux-first)
- Lock-free scheduler internals
- Compiler:
gccwith C17 - Sanitizers: AddressSanitizer + UndefinedBehaviorSanitizer
- Test runner:
ctestwith CMocka unit tests - Static checks:
clang-tidy(optional first pass)
- CMake >= 3.20
- C compiler with C17 support (gcc/clang)
- CMocka development package (
libcmocka-devon Debian/Ubuntu) clang-format
- Configure and build:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debugcmake --build build
- Run tests:
ctest --test-dir build --output-on-failure
- Format source code:
cmake --build build --target format
- Verify formatting only:
cmake --build build --target format-check
- Install hooks:
./scripts/install-hooks.sh
Installed pre-commit hook runs:
clang-formatcheck on staged*.cand*.hfiles- debug build
- test execution via
ctest
Installed pre-push hook runs:
- debug build
- test execution via
ctest