Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Feb 2001 12:46:39 -0800 (PST)
From:      Richard Hodges <rh@matriplex.com>
To:        Matt Dillon <dillon@earth.backplane.com>
Cc:        Nik Clayton <nik@FreeBSD.ORG>, hackers@FreeBSD.ORG
Subject:   Re: Updating mmap(2) [nik@freebsd.org: Re: pipe]
Message-ID:  <Pine.BSF.4.10.10102101235030.79449-100000@mail.matriplex.com>
In-Reply-To: <200102102023.f1AKNMO27394@earth.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 10 Feb 2001, Matt Dillon wrote:

NC:
> :>      mmap - allocate memory, or map files or devices into memory
> :> 
> :> would be better?
> :

RH:
> :While you're at it :-) maybe you could add a few lines suggesting that
> :with the MAP_SHARED flag, this is a useful method of sharing memory 
> :between processes.

>     Not only that, but you can mmap() anonymous memory MAP_SHARED as well,
>     which means the memory is shared across fork().  Theoretically it is
>     possible to share a memory region across an exec*() as well, but I've
>     never been able to get that to work.

Ah, yes.  I forgot to mention the MAP_ANON flag...  My typical usage is
often something like:

  void *retval;
  int   memsize;

  [...]

  retval = mmap(NULL, memsize, PROT_READ | PROT_WRITE,
                MAP_ANON | MAP_SHARED, -1, 0);
  if(retval == MAP_FAILED)
    FAIL
  else
    FORK

Maybe I'm suffering a temporary lapse of clue, but is there some
place where supplemental info (like code snippets) is kept?  This
kind of info might be handy to someone seeing the man page for the
first time, but it doesn't seem quite right to put code samples
in the man pages themselves.  

-Richard

-------------------------------------------
   Richard Hodges   | Matriplex, inc.
      <title>       | 769 Basque Way
  rh@matriplex.com  | Carson City, NV 89706
    775-886-6477    | www.matriplex.com 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.10102101235030.79449-100000>