Which green threads libraries are available for C that can match the performance and ease of use of Haskell's green threads?

Cetin Sert picture Cetin Sert · Jan 16, 2013 · Viewed 7.1k times · Source

I am well used to relying on GHC's forkIO for portable lightweight threads when programming in Haskell.

What are equivalent libraries for C that can provide the same scalibility and ease of use?

Specifically I need C-equivalents of at least the following two functions.

forkIO     :: IO () -> IO ThreadId
killThread ::             ThreadId -> IO ()

I assume for my application, it would be enough if threads only switched on blocking operations rather than being forcefully suspended because all threads block highly frequently for network IO and I only use the splice system call to ask the Linux kernel to push data around between sockets.


Update

This paper has figures and tables comparing

with results favoring Protothreads. As I have not used any and there may also be other libraries, I would love to hear from anyone who has used / developed such libraries.

Answer

Martin Rauscher picture Martin Rauscher · Jan 9, 2016

libMill is probably what you're searching for: http://libmill.org/

It implements user level threads in the Go-Lang channel style.

And it's being developed by the super smart Martin Sústrik, creator of ZeroMQ http://250bpm.com/. So it must be good ☺