From owner-freebsd-hackers Thu Aug 17 18:55: 8 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.129.65]) by hub.freebsd.org (Postfix) with ESMTP id 4EFEF37BE43 for ; Thu, 17 Aug 2000 18:51:29 -0700 (PDT) Received: from Awfulhak.org (tun.AwfulHak.org [194.242.139.173]) by mx1.FreeBSD.org (Postfix) with ESMTP id 45ACF6E41E1 for ; Thu, 17 Aug 2000 17:25:10 -0700 (PDT) Received: from hak.lan.Awfulhak.org (root@hak.lan.awfulhak.org [172.16.0.12]) by Awfulhak.org (8.9.3/8.9.3) with ESMTP id BAA12226; Fri, 18 Aug 2000 01:21:27 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.0/8.11.0) with ESMTP id e7I0LOF43257; Fri, 18 Aug 2000 01:21:24 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200008180021.e7I0LOF43257@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.1.1 10/15/1999 To: Warner Losh Cc: Karl Pielorz , hackers@FreeBSD.ORG, brian@Awfulhak.org Subject: Re: Critical (or equivalent) section in Userland? In-Reply-To: Message from Warner Losh of "Thu, 17 Aug 2000 11:23:37 MDT." <200008171723.LAA12924@harmony.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 18 Aug 2000 01:21:23 +0100 From: Brian Somers Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > In message <399BA212.A84240AE@tdx.co.uk> Karl Pielorz 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 advisory locks won't work (and they almost always will for things > like this), then you could walk the process tree. For all processes > that aren't suspended or yourself, send a SIGSTOP, keep a list. Keep > going through the tree while you keep finding processes. SIGSTOP > can't be caught or blocked, so you know you've stopped them). Do your > operation, then send SIGCONT to all the processes that you sent a > SIGSTOP to. Of course, this will likely be much harder than doing > advisory locking, but might be a way that you might be able to exactly > what you want. Wow, forgive me for saying this, but it must take a warped mind to think of that !!! :-) Now if the original poster could arrange that all the files are either in the same directory or symlinked to the same directory, a quick directory rename (or symlink move) may do the job. If that's not atomic enough, you could always replace that chunk of filesystem with a mount(). > Warner > > P.S. Can you tell I'm partial to advisory locks? -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message