From owner-cvs-all@FreeBSD.ORG Fri Mar 4 16:53:13 2005 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ACA7616A4CE; Fri, 4 Mar 2005 16:53:13 +0000 (GMT) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id DD65A43D1D; Fri, 4 Mar 2005 16:53:10 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.11] (junior-wifi.samsco.home [192.168.254.11]) (authenticated bits=0) by pooker.samsco.org (8.13.1/8.13.1) with ESMTP id j24Gt1CI011546; Fri, 4 Mar 2005 09:55:01 -0700 (MST) (envelope-from scottl@samsco.org) Message-ID: <422891E5.3040402@samsco.org> Date: Fri, 04 Mar 2005 09:50:45 -0700 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.5) Gecko/20050218 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Colin Percival References: <200503031116.22840.jhb@FreeBSD.org> <20050305032619.K18638@delplex.bde.org> <42288FA6.7010102@freebsd.org> In-Reply-To: <42288FA6.7010102@freebsd.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on pooker.samsco.org cc: src-committers@freebsd.org cc: Bruce Evans cc: John Baldwin cc: cvs-src@freebsd.org cc: cvs-all@freebsd.org cc: Daniel Eischen cc: David Xu Subject: Re: cvs commit: src/sys/kern kern_sig.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Mar 2005 16:53:13 -0000 Colin Percival wrote: > Bruce Evans wrote: > >>Sleeping on a stack address is just a bug [...] > > > I was told that this was the canonical way to say "go to sleep and don't > wake up until the timo expires" was to tsleep() with ident equal to > something from the stack. > > If this isn't correct, what is the correct way to do this? I've seen > some code which does tsleep(NULL, ... ), but I was told that was also > wrong. > > Colin Percival The first argument to tsleep/msleep is just a cookie that is supposed to uniquely identify the sleeper for when you want to wake it up. Having colliding cookies isn't terrible, but it means that the other colliding sleepers might get woken up when they don't expect it. Using NULL is no different than using a cookie with a very high probability of collision. The suggestion to use a stack address from the local frame was made because it gives you a fairly good chance of obtaining a unique value. However, as Bruce points out, it's really just a side effect of the MD stack allocation scheme, and is no way a guarantee. Using an address from the global heap is probably a better choice, but since the stacks are also allocated from the global heap now, there really isn't much of a difference. Scott