Re: sleep bug in taskqueue(9)

From: Hans Petter Selasky <hselasky_at_c2i.net>
Date: Fri, 12 Nov 2010 10:06:10 +0100
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
Received on Fri Nov 12 2010 - 08:05:10 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:09 UTC