From owner-freebsd-hackers Sat Feb 10 12:47: 8 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.matriplex.com (ns1.matriplex.com [208.131.42.8]) by hub.freebsd.org (Postfix) with ESMTP id 890DD37B401; Sat, 10 Feb 2001 12:46:45 -0800 (PST) Received: from mail.matriplex.com (mail.matriplex.com [208.131.42.9]) by mail.matriplex.com (8.9.2/8.9.2) with ESMTP id MAA82929; Sat, 10 Feb 2001 12:46:39 -0800 (PST) (envelope-from rh@matriplex.com) Date: Sat, 10 Feb 2001 12:46:39 -0800 (PST) From: Richard Hodges To: Matt Dillon Cc: Nik Clayton , hackers@FreeBSD.ORG Subject: Re: Updating mmap(2) [nik@freebsd.org: Re: pipe] In-Reply-To: <200102102023.f1AKNMO27394@earth.backplane.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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. | 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