Re: Transactions with files?

From: Ed Prochak (ed.prochak_at_magicinterface.com)
Date: 07/20/05


Date: 20 Jul 2005 09:38:42 -0700


Toni wrote:
> Hi,
>
> I'm writing a C program that should do something like transactions on
> files.
> I have several reader processes and one writer, and I have to make sure
> that the writer either writes everything or nothing to (part of) a
> file.
> So I thought of COW (copy-on-write), but how to do that?
> mmap() with MAP_PRIVATE can give me a copy of the (part of the) file to
> work with. But how can I write the changes back to the original file so
> that other processes would see those changes? MAP_PRIVATE prevents
> writing changes to the original file, so I can't use msync().
> AIX has deferred write capability (open() with O_DEFER flag)- changes
> are written to a file only when fsync() is called. Linux doesn't seem
> to have such a capability.
>
> Any ideas?
>
> Cheers, Toni

Look at some of the open source databases.
You might consider that the writer only does a write on the commit. You
can do that by caching the individual writes in memory or in a
transaction log file. At the commit point, all the data is written at
once.

Note that the other processes won't see changes to the file unless they
go back and reread it.

So BTW, when is your assignment due? Not too many folks take summer
classes.

  Ed



Relevant Pages

  • Re: How to receive a buck from the Net?(Was: Re: 1 dollar free ... SPAM)
    ... short of someone actually writing you a personal check for a ... Any transaction system I know will leave you with just about 50 ... cents or less making such tiny transactions a nuisance. ... of sites will ask for 0.10 USD or so to read a page. ...
    (alt.internet.search-engines)
  • Re: Disappearing Application -- Oracle Related
    ... I'm not using Autocommit. ... > application - writing to a text file or a series of ... > ShowMessage statements to help your narrow down the problem. ... several hundreds of transactions. ...
    (comp.lang.pascal.delphi.misc)
  • Re: How to receive a buck from the Net?(Was: Re: 1 dollar free ... SPAM)
    ... short of someone actually writing you a personal check for a ... Any transaction system I know will leave you with just about 50 ... cents or less making such tiny transactions a nuisance. ... of sites will ask for 0.10 USD or so to read a page. ...
    (alt.internet.search-engines)