*BSD News Article 31481


Return to BSD News archive

Xref: sserve comp.unix.programmer:17517 comp.unix.questions:50364 comp.unix.bsd:14136
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!netnews.upenn.edu!news.cc.swarthmore.edu!psuvax1!news.pop.psu.edu!news.cac.psu.edu!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!centre.univ-orleans.fr!univ-lyon1.fr!ensta!itesec!keltia.frmug.fr.net!not-for-mail
From: roberto@keltia.frmug.fr.net (Ollivier Robert)
Newsgroups: comp.unix.programmer,comp.unix.questions,comp.unix.bsd
Subject: Re: mmap memory/disk synchronization
Date: 4 Jun 1994 13:14:47 +0200
Organization: A Happy FreeBSD-current Usenet Site
Lines: 39
Message-ID: <2spnnl$e9@keltia.frmug.fr.net>
References: <2so8tj$fkp@netnews.upenn.edu>
Reply-To: roberto@hsc.fr.net (Ollivier Robert)
NNTP-Posting-Host: keltia.frmug.fr.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

In article <2so8tj$fkp@netnews.upenn.edu>,
David Blackman <blackman@hodgkin.med.upenn.edu> wrote:
>Using SunOS 4.x, is there a way to insure that a disk file and a
>segment of memory mapped with mmap are consistent - i.e. to guarantee
>that all writes to the memory segment are on disk?  I would like
>something like fflush but fflush wants a FILE * parameter and mmap
>wants an int fd.

I don't have a Sun handy but check whether it has msync(2) :
------------------------------------------------------------
NAME
       msync - synchronize a mapped region

SYNOPSIS
       msync(addr, len)
       caddr_t addr;
       int len;

DESCRIPTION
       The  msync  system  call writes any modified pages back to
       the filesystem and updates the file modification time.  If
       len  is 0, all modified pages within the region containing
       addr will be flushed; if len is non-zero, only  the  pages
       containing addr and len succeeding locations will be exam-
       ined.  Any required synchronization of memory caches  will
       also  take place at this time.  Filesystem operations on a
       file that is mapped for shared  modifications  are  unpre-
       dictable except after an msync.

SEE ALSO
       msync.2, munmap.2, mprotect.2, madvise.2, mincore.2

                           May 27, 1991                         1
------------------------------------------------------------
Extracted from FreeBSD.
-- 
Ollivier ROBERT                                           roberto@hsc.fr.net
Hervé Schauer Consultants                Ollivier.Robert@keltia.frmug.fr.net
PERL / MIME / PGP 2.6ui     FreeBSD keltia 1.1.0(Current) CURRENT_092#0 i386