From owner-freebsd-hackers@FreeBSD.ORG Tue May 8 16:07:21 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C4FC21065673 for ; Tue, 8 May 2012 16:07:21 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta02.emeryville.ca.mail.comcast.net (qmta02.emeryville.ca.mail.comcast.net [76.96.30.24]) by mx1.freebsd.org (Postfix) with ESMTP id A9B2A8FC0C for ; Tue, 8 May 2012 16:07:21 +0000 (UTC) Received: from omta20.emeryville.ca.mail.comcast.net ([76.96.30.87]) by qmta02.emeryville.ca.mail.comcast.net with comcast id 7U6f1j0051smiN4A2U7F4G; Tue, 08 May 2012 16:07:15 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta20.emeryville.ca.mail.comcast.net with comcast id 7U7E1j00W4NgCEG8gU7Evs; Tue, 08 May 2012 16:07:15 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q48G7CWF088937 for ; Tue, 8 May 2012 10:07:12 -0600 (MDT) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="us-ascii" Date: Tue, 08 May 2012 10:07:12 -0600 Message-ID: <1336493232.1503.29.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Subject: Calling tsleep(9) with interrupts disabled X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2012 16:07:21 -0000 I just realized that I've accidentally coded a sequence similar to this in a driver: s = intr_disable(); // do stuff here tsleep(sc, 0, "twird", hz / 4); // more stuff intr_restore(s); Much to my surpise this works, including waking up due to wakeup(sc) being called from an interrupt handler. So apparently tsleep() results in interrupts being re-enabled during the sleep, although nothing in the manpage says that will happen. Can I safely rely on this behavior, or is it working by accident? (Please no lectures on the evils of disabling interrupts... This is not a multi-GHz multi-core Xeon, it's a 180mhz embedded SoC with buggy builtin devices that will drop or corrupt data if an interrupt happens during the "do stuff here" part of the code.) -- Ian