From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 11 20:23:33 2007 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2438916A417; Sat, 11 Aug 2007 20:23:33 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.freebsd.org (Postfix) with ESMTP id 82D4C13C45B; Sat, 11 Aug 2007 20:23:32 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (twgr8wmy9pl6gz5w@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id l7BJpxet048901; Sat, 11 Aug 2007 12:51:59 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id l7BJpwQ9048900; Sat, 11 Aug 2007 12:51:58 -0700 (PDT) (envelope-from jmg) Date: Sat, 11 Aug 2007 12:51:58 -0700 From: John-Mark Gurney To: Roman Divacky Message-ID: <20070811195158.GY99491@funkthat.com> Mail-Followup-To: Roman Divacky , hackers@freebsd.org References: <20070811124612.GA21695@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070811124612.GA21695@freebsd.org> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: hackers@freebsd.org Subject: Re: strange KASSERT in _sleep() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Aug 2007 20:23:33 -0000 Roman Divacky wrote this message on Sat, Aug 11, 2007 at 14:46 +0200: > tsleep() maps to _sleep() with lock = NULL, > > the _sleep() contains this: > > KASSERT(timo != 0 || mtx_owned(&Giant) || lock != NULL || > ident == &lbolt, ("sleeping without a lock")); > > > which simplifies for tsleep(foo, ...) where foo != lbolt to > "timo != 0 || mtx_owned(&Giant)" > > why do I have to hold Giant or have timo != 0 when calling tsleep? To prevent a deadlock.. It would be possible for you to miss your wakeup if you don't have a lock (such as Giant) held... By forcing a timeout, you guarantee that it will check the condition sometime in the future... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."