OpenAmiga (382/959)

From:Patrick Roberts
Date:9 Aug 2000 at 03:20:26
Subject:Re: fork() (Was: Re: AMIOPEN: ave_open())

Aaron Optimizer Digulla wrote:
>
> On Tue, Aug 08, 2000 at 09:50:14AM -0700, Patrick Roberts wrote:
>
> > Just to add to your description of what fork() does, and one of the main
> > reasons I use fork() is that the child and parent process share memory until
> > one does a write, then only the page that the process writes to is copied and
> > tracked. This is great for anything wanting to take advantage of multi-proc
> > set-ups as the performance increase is much faster than using threads. At
> > least this is how it works in Linux and IRIX.
>
> :-/ How about using mmap() for this ?
>

mmap() only gives you access to memory, the fork manager tracks writes and
duplicates pages when written to. For example, you can open a huge file, fork,
and each process can change 1 byte and the only duplication in RAM is the page
the changed byte lives in. Additionally, each child retains the mapping of the
parent- if you had some allocated memory as *image in the parent, the same * is
retained in the child, even though some physical pages may differ between the
two- the area appears contiguous to each process.

-Pat

> --
> ==============================================
> Sowatec AG, CH-8330 Pf�ffikon (ZH)
> Witzbergstr. 7, http://www.sowatec.com
> Tel: +41-(0)1-952 55 55
> Fax: +41-(0)1-952 55 66
> ----------------------------------------------
> Aaron "Optimizer" Digulla, digulla@sowatec.com
> ==============================================
> Subscribe/Unsubscribe: open-request@amiga.com
> Amiga FAQ: http://www.amiga.com/faq.html
Subscribe/Unsubscribe: open-request@amiga.com
Amiga FAQ: http://www.amiga.com/faq.html