Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Dec 1996 13:01:45 -0700
From:      Sean Kelly <kelly@fsl.noaa.gov>
To:        "Eric L. Hernes" <erich@lodgenet.com>
Cc:        "Marc G. Fournier" <scrappy@hub.org>, hackers@FreeBSD.ORG
Subject:   Re: Multiple Buffer allocation of Shared Memory
Message-ID:  <32ADC1A9.3832@fsl.noaa.gov>
References:  <199612101935.NAA16873@jake.lodgenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Eric L. Hernes wrote:

> One way, is to open a (previously agreed upon) named file that
> will be used to share data, ftruncate() it to the size you want,
> then mmap() it.  Other processes can open and mmap() this same file
> to get at the data.

But bear in mind where the file is located.  If it's on a UFS, then your
system will have to do physical I/O to update the file on disk as
processes mmap'ing it make updates.  That's why it's often better to
locate mmap'd files used for IPC on an MFS filesystem.

Sample /etc/fstab entries to mount MFS on /tmp:

/dev/sd0s4b                     none            swap    sw        0 0
/dev/sd0s4b                     /tmp            mfs     rw        0 0

Of course, if you need the file's contents to be persistent across
reboots, then MFS isn't such a bad idea.

> and mmap() can buy you is persistance of data across a reboot(), whether
> that is good or bad is up to you.

Hey, that's what I just said!  ;-)

-- 
Sean Kelly                          
NOAA Forecast Systems Laboratory    kelly@fsl.noaa.gov
Boulder Colorado USA                http://www-sdd.fsl.noaa.gov/~kelly/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32ADC1A9.3832>