linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Heuer <dh@triple-media.com>
To: linux-c-programming@vger.kernel.org
Subject: how to best map/buffer a file to memory by being able to lock sequences thread-safe
Date: Sat, 13 Oct 2007 00:01:58 +0200	[thread overview]
Message-ID: <20071013000158.d011bc82.dh@triple-media.com> (raw)

hello

i tried to write a memory cache for a file and keep it in sync with the
file while threads or foreign processes are writing safely to it. then
i found mmap and lockf but the both don't work together. i studied all
the other alternatives i found, like fcntl or flockfile, but they
don't support the one or the other action. for example, fcntl locks are
not based on a per-thread base. flockfile only works on the full FILE
object, etc. also, if i don't use mmap, as far as i can see, i have to
map the file to a buffer myself, which causes sync-problems especially
with foreign processes.

how can i reach the same level of features and comfort like with lockf
and mmap without one of the both and by staying posix-compliant (at
least)?

by the way: can i lock sections of a plain memory buffer (mmap'ed or
allocated with malloc or whatever) like i can do with fcntl or lockf
to have threads not running over eachother?

regards,
dennis heuer

             reply	other threads:[~2007-10-12 22:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-12 22:01 Dennis Heuer [this message]
2007-10-13 16:00 ` how to best map/buffer a file to memory by being able to lock sequences thread-safe Glynn Clements
2007-10-15 15:46 ` Dennis Heuer
2007-10-16 10:54   ` Glynn Clements
2007-10-16 17:28     ` Dennis Heuer
2007-10-16 18:44       ` Glynn Clements
2007-10-17 14:42         ` Bryan Christ

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=20071013000158.d011bc82.dh@triple-media.com \
    --to=dh@triple-media.com \
    --cc=linux-c-programming@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;
as well as URLs for NNTP newsgroup(s).