[Libwebsockets] Multithreading on Win

Andy Green andy at warmcat.com
Sun Mar 14 11:13:43 CET 2021

On 3/14/21 10:06 AM, Mykola Stryebkov wrote:
> Hi,
> I’m curious what is the reason to limit LWS_MAX_SMP to 1 on Win? And 

Previously there was no pthreads supported there... I added pthreads 
support in the windows platform to support Sai using lws_spawn.

> what has to be done to allow proper multithreading there?

I don't know what "proper multithreading" means to you but in the end 
lws is predicated around single threaded event loops, the SMP stuff just 
tries to let you have n event loop threads so you can scale serving 
across more cores / threads in the mass serving case.

LWS_MAX_SMP > 1 adds pthreads based locking inside lws to try to solve 
lws internal contentions, but it leaves it up to you to lock 
multithreaded access to objects shared between different service threads.

Windows is really not a good substrate for serving things, like its 
default 64 socket limit in WSA, it's unlikely to be the right answer.


More information about the Libwebsockets mailing list