Bringing Go-Flavored Concurrency to C with POSIX Threads

Go-Flavored Concurrency in C

Bringing Go-Flavored Concurrency to C with POSIX Threads

I explored how closely we can mimic Go's effortless concurrency in C using only POSIX threads for my Solod project. While native OS threads lack the efficiency of lightweight goroutines, I found that with honest tradeoffs, we can build a robust system using mutexes, condition variables, and worker pools. This approach offers a practical path to concurrent C without a runtime, though it requires careful management of thread creation and resource usage.

In the end, I came to the conclusion that you can do quite a lot with pthreads — as long as you're honest about the tradeoffs.
  1. BoingBoomTschak

    Just a small "ackchyually": Go is basically a modern Limbo which is itself based on Alef and there was an official "Alef for C" thing in Plan 9 in libthread (https://9p.io/magic/man2html/2/thread)

    EDIT: looks like it was ported on UNIX as part of Plan9Port (https://github.com/9fans/plan9port/blob/master/src/libthread...)

  2. dandersch

    There is also libmill/libdill, which implements go-style coroutines using setjmp and is usable directly from C (not just as a transpilation target).

    https://libmill.org/

  3. fsmv

    But select statements are the most important part, and second to that is the fact that goroutines are low cost user space threads

More from this day

2026-07-13