Optimal multithread model

Marc Lehmann schmorp at schmorp.de
Wed Mar 17 01:53:29 CET 2010


On Tue, Mar 16, 2010 at 03:40:46PM +0100, Christophe Meessen <christophe at meessen.net> wrote:
> With threads we can easily set up a pool of worker threads that easily  
> and efficiently pick up the context associated to the connection  
> becoming active. I don't see how an equivalent model can be efficiently  
> implemented with processes.

Depends very much on the protocol and the OS abilities - pthread does work
over process boundaries (but maybe not on the platform where you need it),
as does accept() and read() on a shared fd. GNUL/Linux can selectively
share the fd table without sharing anything else (but you have no good API
for that, as it isn't supported by pthreads etc.).

> I would prefer it was possible to do it with processes because they have  
> the benefit of a separate  memory space which is much better for  
> security and robustness. But I couldn't find a way to do it as easily  
> and efficiently as with threads.

For your specific problem, that could well be true. Things aren't black or
white, there is grey stuff too :)

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list