From owner-freebsd-current Mon Aug 7 15:21:55 2000 Delivered-To: freebsd-current@freebsd.org Received: from mailgate.originative.co.uk (mailgate.originative.co.uk [194.217.50.228]) by hub.freebsd.org (Postfix) with ESMTP id BF5C237B8DF; Mon, 7 Aug 2000 15:21:51 -0700 (PDT) (envelope-from paul@originative.co.uk) Received: from originative.co.uk (lobster.originative.co.uk [194.217.50.241]) by mailgate.originative.co.uk (Postfix) with ESMTP id 4CB961D13D; Mon, 7 Aug 2000 23:21:48 +0100 (BST) Message-ID: <398F367C.27DD39DA@originative.co.uk> Date: Mon, 07 Aug 2000 23:21:48 +0100 From: Paul Richards Organization: Originative Solutions Ltd X-Mailer: Mozilla 4.74 [en] (X11; U; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: dg@root.com Cc: Poul-Henning Kamp , Alfred Perlstein , Matt Dillon , Mike Smith , Stephen McKay , freebsd-current@FreeBSD.ORG, dillon@FreeBSD.ORG Subject: Re: Ugly, slow shutdown References: <200008072149.OAA04253@implode.root.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG David Greenman wrote: > > >In the particular case of sleeping though, a woken process does need to > >check the condition that it slept on because one of the other processes > >sleeping on that resource may have had a chance to run first and changed > >some state. So as a general rule, you shouldn't assume that everything > >is fine when you return from being asleep because it might not be. > > No, that's not true, and there are many examples in the kernel where a > bogus wakeup would lead to bad things happening. I recall some code in the > advisory locking code, and VM system, that assume that there is only one > wakeup event and that the thing causing it assures that certain other > things have occured before issuing it. That's just the way it has worked > since the dawn of time. I did say "as a general rule". If you know that "by design" nothing else is going to mess with what you're sleeping on before you wake up then you can make tighter optimisations but that's not the general case. There is such a thing as over optimisation though and for the sake of a simple if statement it is probably better to write code that is robust to changes made elsewhere in the system rather than squeeze every inch of performance out of the code, unless there's a real need to optimize in that particular area. Paul. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message