[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to spawn a server?





Mads Bondo Dydensborg wrote:
> On Mon, 9 Sep 2002, Francesco Orsenigo wrote:
> 
> 
>>I was thinking to pipe(), socketpair() and then fork() only when i really 
>>need a server, but i don't know how does fork() works...
>>If I fork() a program with lots af allocated memory, low-level hardware 
>>access, and lots of open descriptors, all this will be copied?
> 
> 
> I am pretty sure, at least on linux, fork works with "copy on write" 
> semantics. That is, stuff will be copied, but not before you actually 
> write to it. So, read only stuff, like maps, textures, etc, will never be 
> copied.

Under Linux, 'fork' is a thin layer built on top of 'clone'.

Clone gives you a bunch of option flags that allow you to specify
*exactly* what's shared between the two processes that result.

For portability, I'd go with pthreads.


----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
        http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
        http://prettypoly.sf.net http://freeglut.sf.net
        http://toobular.sf.net   http://lodestone.sf.net