From: Chris Friesen <chris_friesen@sympatico.ca>
To: linux-kernel@vger.kernel.org
Subject: nitpicky questions regarding mmap() and msync()
Date: Thu, 09 Aug 2001 20:41:18 -0400 [thread overview]
Message-ID: <3B732DAE.CD117CBA@sympatico.ca> (raw)
A couple questions about mmap()'d files.
1) If I have an mmap()'d file and I write to it and then I am hit with a SIGKILL
before I have a chance to msync(), am I guaranteed that changes I've made to the
information in the file will be available if I restart and try to mmap() the
same file? The man page says only that there is no guarantee that changes are
written back to disk if msync() is not called, but some informal testing seems
to indicate that changes are in fact written out. Is this a timing issue or
does the system guarantee this?
2) If I make changes to the contents of an mmap()'d file, am I guaranteed that
the order I make the changes is the same order that they will be available to
another process that has mmap()'d the same file? (Or can I be bit by
optimization reordering? If this is the case, can I get around this by reading
it as volatile and using the barrier() macro?)
The basic idea is that I have a state file stored in ramdisk in which I keep
track of some system state variables. This gets mmap()'d into memory. If my
process gets killed for whatever reason it can restart and read this file to
check the state. One of the variables in this file is a flag that says whether
or not its a valid file. If the file is invalid then more drastic recovery
measures must be taken. I want to be sure that if I clear the flag before doing
any multi-stage operations and then set it after I'm done, I can always
guarantee that if that variable is set then the contents are valid. I would
also like to avoid calling msync() after every change if I can avoid it.
Anyone know the definitive answers to these questions? I don't need posix
standard behaviour, just what linux currently does (and is likely to do in the
future, if it is different).
Thanks,
Chris
next reply other threads:[~2001-08-10 0:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-10 0:41 Chris Friesen [this message]
2001-08-10 11:12 ` nitpicky questions regarding mmap() and msync() Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B732DAE.CD117CBA@sympatico.ca \
--to=chris_friesen@sympatico.ca \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox