diff options
| author | Sam Leffler <sam@FreeBSD.org> | 2005-04-24 16:52:45 +0000 |
|---|---|---|
| committer | Sam Leffler <sam@FreeBSD.org> | 2005-04-24 16:52:45 +0000 |
| commit | f4581151a8aad772d7f45f9de2ac8882d9147a13 (patch) | |
| tree | 5a6fe7fb2312cf12d5ca0ea2b9d79549f4f97743 | |
| parent | c770569c74d63dd45146272ab6ebee95befd34ff (diff) | |
Notes
| -rw-r--r-- | sys/kern/subr_taskqueue.c | 7 | ||||
| -rw-r--r-- | sys/sys/_task.h | 7 | ||||
| -rw-r--r-- | sys/sys/taskqueue.h | 1 |
3 files changed, 6 insertions, 9 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index 7758fbdb1a27..9d0ada456d1a 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -51,6 +51,7 @@ struct taskqueue { const char *tq_name; taskqueue_enqueue_fn tq_enqueue; void *tq_context; + struct task *tq_running; struct mtx tq_mutex; }; @@ -186,13 +187,13 @@ taskqueue_run(struct taskqueue *queue) STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link); pending = task->ta_pending; task->ta_pending = 0; - task->ta_flags |= TAF_PENDING; + queue->tq_running = task; mtx_unlock(&queue->tq_mutex); task->ta_func(task->ta_context, pending); mtx_lock(&queue->tq_mutex); - task->ta_flags &= ~TAF_PENDING; + queue->tq_running = NULL; wakeup(task); } @@ -209,7 +210,7 @@ taskqueue_drain(struct taskqueue *queue, struct task *task) { WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "taskqueue_drain"); mtx_lock(&queue->tq_mutex); - while (task->ta_pending != 0 || (task->ta_flags & TAF_PENDING)) { + while (task->ta_pending != 0 || task == queue->tq_running) { msleep(task, &queue->tq_mutex, PWAIT, "-", 0); } mtx_unlock(&queue->tq_mutex); diff --git a/sys/sys/_task.h b/sys/sys/_task.h index 4eb6d644d450..2a51e1b07b97 100644 --- a/sys/sys/_task.h +++ b/sys/sys/_task.h @@ -41,13 +41,10 @@ typedef void task_fn_t(void *context, int pending); struct task { STAILQ_ENTRY(task) ta_link; /* link for queue */ - int ta_pending; /* count times queued */ - int ta_priority; /* priority of task in 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 */ - int ta_flags; /* Flags */ }; -#define TAF_PENDING 0x1 /* Task is being run now */ - #endif /* !_SYS__TASK_H_ */ diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h index 31bd9f27b242..6a9de516c8ca 100644 --- a/sys/sys/taskqueue.h +++ b/sys/sys/taskqueue.h @@ -70,7 +70,6 @@ void taskqueue_thread_enqueue(void *context); (task)->ta_priority = (priority); \ (task)->ta_func = (func); \ (task)->ta_context = (context); \ - (task)->ta_flags = 0; \ } while (0) /* |
