I am looking for user-mode multi-threading library/framework for C++ under Linux. I am familiar with boost::thread and ACE_Thread_Manager but AFAIK both of them eventually use OS native thread's support.
Suggestions will be highly appreciated.
I am looking for user-mode multi-threading library/framework for C++ under Linux. I am familiar with boost::thread and ACE_Thread_Manager but AFAIK both of them eventually use OS native thread's support.
Suggestions will be highly appreciated.
GNU PTH: http://www.gnu.org/software/pth/
It's using cooperative multithreading, which is why it's used in GnuPG (which for security reasons doesn't want real threads, but for responsiveness reasons needs threads).
Is MTasker the kind of thing you're looking for? It's also a cooperative multi-tasking library. You might also want to consider just whipping up some state machines.
Also check out State Threads and MIT Pthreads.
This tool will assist in the generation of hierarchical state machines, which could be used for this purpose: CHSM
You may want to check out Intel Thread Building Blocks. (TBB)
http://www.threadingbuildingblocks.org/
It tries to abstract a lot of the threading concepts away from the programmer while having he/she take more of a task based approach to parallelism.
If you want to thread for io type operations you could consider multi-plexing with select
I blogged on this topic a while back: http://yz.mit.edu/wp/cooperative-threads-for-cc/.
At the time I had compared the front-runners State-Threads and GNU Pth, and based on not-too-careful examination of the documentation and code, I walked away with greater confidence in the systems hackery in ST than Pth, but I can't recall the specifics. I've had a positive experience with ST, so never really tried out Pth.
The only thing that worried me about ST is its disclaimer about its (inability to) interop with pthreads. I had used both in the same project (another reason why Pth probably doesn't fit the bill is that it uses all the same symbol names as pthreads), and I never ran into any issues, but I never stress-tested the combination.
Would be interested in knowing your (and others') experiences WRT these two particular libraries.