Date: Thu, 17 Aug 2000 17:38:22 -0700 (PDT) From: Archie Cobbs <archie@whistle.com> To: David Malone <dwmalone@maths.tcd.ie> Cc: Karl Pielorz <kpielorz@tdx.co.uk>, hackers@FreeBSD.ORG Subject: Re: Critical (or equivalent) section in Userland? Message-ID: <200008180038.RAA02350@bubba.whistle.com> In-Reply-To: <20000817100652.A31452@walton.maths.tcd.ie> from David Malone at "Aug 17, 2000 10:06:52 am"
next in thread | previous in thread | raw e-mail | index | archive | help
David Malone writes: > > I'm writing a program under FreeBSD 3.X that has been forced into having to > > make a number of rename() calls that must be completed atomically (i.e. all > > together) without the process being interrupted, or any other process being > > allowed to run... > > If all the files exist below one directory you could swap the > directories with two renames, but that won't be atomic either. I > think your best bet would be rethink what you want to do. It could still work as long as at startup you check for any half-completed operation and finish it, e.g.: mkdir mydir.new copy/modify files in mydir.new mv mydir mydir.old mv mydir.new mydir Then on startup (e.g., after a crash), if "mydir" doesn't exist, simply "mv mydir.new mydir; rm -rf mydir.old" before proceeding. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008180038.RAA02350>