diff options
| author | Warner Losh <imp@FreeBSD.org> | 2004-10-05 04:16:01 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2004-10-05 04:16:01 +0000 |
| commit | 14889b422910d683b06059f5b0eb340e4cc590d4 (patch) | |
| tree | ad9188e83f96f6272ded257087c644b20048745e /sys/kern/subr_taskqueue.c | |
| parent | 8aebfc9c7edfee486315a7a4abbcbe835c4a8504 (diff) | |
Notes
Diffstat (limited to 'sys/kern/subr_taskqueue.c')
| -rw-r--r-- | sys/kern/subr_taskqueue.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index a10e7107bd89..7758fbdb1a27 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -186,11 +186,14 @@ 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; mtx_unlock(&queue->tq_mutex); task->ta_func(task->ta_context, pending); mtx_lock(&queue->tq_mutex); + task->ta_flags &= ~TAF_PENDING; + wakeup(task); } /* @@ -201,6 +204,17 @@ taskqueue_run(struct taskqueue *queue) mtx_unlock(&queue->tq_mutex); } +void +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)) { + msleep(task, &queue->tq_mutex, PWAIT, "-", 0); + } + mtx_unlock(&queue->tq_mutex); +} + static void taskqueue_swi_enqueue(void *context) { |
