From owner-freebsd-drivers@FreeBSD.ORG Wed Jan 28 13:28:48 2009 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE33F106564A for ; Wed, 28 Jan 2009 13:28:48 +0000 (UTC) (envelope-from philip-freebsd1@soeberg.net) Received: from em002a.cxnet.dk (em002a.cxnet.dk [87.72.115.243]) by mx1.freebsd.org (Postfix) with ESMTP id A711C8FC14 for ; Wed, 28 Jan 2009 13:28:48 +0000 (UTC) (envelope-from philip-freebsd1@soeberg.net) Received: from em002a.cxnet.dk (localhost [127.0.0.1]) by em002a.cxnet.dk (Postfix) with ESMTP id 01345174B41 for ; Wed, 28 Jan 2009 14:12:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.1.7-deb (2006-10-05) on em002a.cxnet.dk X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED,TW_SK autolearn=failed version=3.1.7-deb Received: from em002a.cxnet.dk (localhost [127.0.0.1]) by em002a.cxnet.dk (Postfix) with ESMTP id DE033174B43 for ; Wed, 28 Jan 2009 14:12:06 +0100 (CET) Received: from [87.72.90.138] (unknown [87.72.90.232]) by em002a.cxnet.dk (Postfix) with ESMTP id CF62F174B41 for ; Wed, 28 Jan 2009 14:12:06 +0100 (CET) Received: from [10.240.240.149] ([77.244.198.2]) (authenticated user philip@soeberg.net) by [87.72.90.138] for freebsd-drivers@freebsd.org; Wed, 28 Jan 2009 14:12:00 +0100 Message-ID: <498059A4.7030909@soeberg.net> Date: Wed, 28 Jan 2009 14:12:04 +0100 From: Philip S User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AV-Checked: ClamAV using ClamSMTP Subject: taskqueue(9); taskqueue_thread usage from within interrupt context on BSD6.x X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2009 13:28:49 -0000 Hi, I need to defer part of my interrupt handler to a kernel thread and am currently doing this by using my own thread based on taskqueue(9) (via taskqueue_create_fast -> taskqueue_start_threads) My original support target where FreeBSD 6.3 and newer but now I need to support the entire 6 branch and in 6.0 taskqueue_start_threads does not exist. So, in taskqueue(9) for BSD6.0 the following is written: >>> The thread queue can be used, for instance, by interrupt level routines that need to call kernel functions that do things that can only be done from a thread context. (e.g., call malloc with the M_WAITOK flag.) <<< This is excellent. To conserve resources I can use the predefined [taskqueue_thread] symbol and enqueue on that in my interrupt handler, instead of reverting to kthreads. But how? taskqueue_thread is at boot constructed as an MTX_DEF mutex and 6.0 taskqueue_enqueue does not detect the type of mutex for the passed taskqueue pointer, so I must use taskqueue_enqueue_fast, which obviously does not work on taskqueue_thread. (Can't go mtx_lock_spin() on MTX_DEFs, and can't go use mtx_lock() from within an interrupt context) How am I supposed to implement that above snippet from within my interrupt context handler? Thanx, /Phil