4 ms·
You might find my epollserver interesting. It multiplexes multiple clients (sockets) over a thread, so you can write an event loop in each thread and serve far
by samsquire 4y ago
You might find my epollserver interesting.
It multiplexes multiple clients (sockets) over a thread, so you can write an event loop in each thread and serve far more requests per thread than you could if it was one thread per client or one process per client. (epollserver_threaded.c)
It uses a thread safe multiconsumer multiproducer ringbuffer to communicate between threads.
https://github.com/samsquire/epoll-server https://github.com/samsquire/epoll-server
I use Alexander Krizhanovsky's of Tempesta technologies Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
https://www.linuxjournal.com/content/lock-free-multi-producer-multi-consumer-queue-ring-buffer https://www.linuxjournal.com/content/lock-free-multi-produce...
- shanebellone 4y agoThis sounds really interesting. Thanks for the share.
- samsquire 4y agoThanks for your kind thanks. I'm currently working on a generalised approach to structuring multiple multithreaded components that run kernel threads and lightweight threads similar to golang. My 1:M:N userspace scheduler multiplexes N lightweight threads onto M kernel threads but it's a different repository. It has one kernel thread and preempts loops by setting them to their limit. Ideally they should be merged into one codebase. https://GitHub.com/samsquire/preemptible-thread https://GitHub.com/samsquire/preemptible-thread