5 ms·
It uses "user-space threads" similar to ucontext (swapcontext(3)). I have my own version: https://github.com/reginaldl/fcontext https://github.com/reginaldl/fco
by regi 12y ago
It uses "user-space threads" similar to ucontext (swapcontext(3)). I have my own version:
https://github.com/reginaldl/fcontext https://github.com/reginaldl/fcontext
Once the stack allocated for a thread, context switches are almost as cheap as a function call.
RiNOO has an event driven scheduler, based on epoll, which resume/release these user-space threads (that I call tasks) according to pending IOs.
The library provides with IO functions (read, write...) which use the RiNOO scheduler.
As a bonus, real threading is quite easy: just need to run a scheduler per thread (see examples with multi-threading).
- brown-dragon 12y agoThat's really interesting - thanks.