From owner-freebsd-current@FreeBSD.ORG Fri Nov 12 09:05:10 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4571C10656A8 for ; Fri, 12 Nov 2010 09:05:10 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe05.swip.net [212.247.154.129]) by mx1.freebsd.org (Postfix) with ESMTP id C0DDA8FC19 for ; Fri, 12 Nov 2010 09:05:09 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=5OBHFxb9I47YZ7HELXzI6cL6pwPTRnd5uxbD1DPQ4WY= c=1 sm=1 a=WrOSKJTHxIAA:10 a=8nJEP1OIZ-IA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=ufIGlTigpa4yK7jz1iQA:9 a=koMamTD_mdDjrzO4wUYA:7 a=9-pG42uRGKA6spH_fxcGWkS4wjEA:4 a=wPNLvfGTeEIA:10 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe05.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 47553019; Fri, 12 Nov 2010 10:05:07 +0100 From: Hans Petter Selasky To: freebsd-current@freebsd.org Date: Fri, 12 Nov 2010 10:06:10 +0100 User-Agent: KMail/1.13.5 (FreeBSD/8.1-STABLE; KDE/4.4.5; amd64; ; ) References: <06D5F9F6F655AD4C92E28B662F7F853E039E389A@seaxch09.desktop.isilon.com> In-Reply-To: <06D5F9F6F655AD4C92E28B662F7F853E039E389A@seaxch09.desktop.isilon.com> X-Face: +~\`s("[*|O,="7?X@L.elg*F"OA\I/3%^p8g?ab%RN'( =?iso-8859-1?q?=3B=5FIjlA=3A=0A=09hGE=2E=2EEw?=, =?iso-8859-1?q?XAQ*o=23=5C/M=7ESC=3DS1-f9=7BEzRfT=27=7CHhll5Q=5Dha5Bt-s=7Co?= =?iso-8859-1?q?TlKMusi=3A1e=5BwJl=7Dkd=7DGR=0A=09Z0adGx-x=5F0zGbZj=27e?=(Y[(UNle~)8CQWXW@:DX+9)_YlB[tIccCPN$7/L' MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201011121006.10183.hselasky@c2i.net> Cc: Matthew Fleming Subject: Re: sleep bug in taskqueue(9) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Nov 2010 09:05:10 -0000 On Thursday 29 April 2010 01:59:58 Matthew Fleming wrote: > struct task { > - STAILQ_ENTRY(task) ta_link; /* link for queue */ > - u_short ta_pending; /* count times queued */ > - u_short ta_priority; /* Priority */ > - task_fn_t *ta_func; /* task handler */ > - void *ta_context; /* argument for handler */ > + STAILQ_ENTRY(task) ta_link; /* (q) link for queue */ > + u_char ta_flags; /* (q) state of this task */ > +#define TA_FLAGS_RUNNING 0x01 > + u_short ta_pending; /* (q) count times queued */ > + u_short ta_priority; /* (c) Priority */ > + task_fn_t *ta_func; /* (c) task handler */ > + void *ta_context; /* (c) argument for handler */ Hi, I would rather implement TAILQ_ENTRY() here, and put some magic in the "tqe_prev" field, hence the u_char you add, will be padded to a bigger size on non-intel platforms anyway. task->ta_pending = 0; - queue->tq_running = task; + task->ta_entry.tqe_prev = (void *)1; TQ_UNLOCK(queue); task->ta_func(task->ta_context, pending); TQ_LOCK(queue); - queue->tq_running = NULL; + task->ta_entry.tqe_prev = (void *)0; wakeup(task); } ... + while (task->ta_entry != (void *)0) --HPS