summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2004-08-08 02:37:22 +0000
committerjmg <jmg@FreeBSD.org>2004-08-08 02:37:22 +0000
commit6967b9b093520d10a58f8d8ff6474706d19326b9 (patch)
tree6e1171646e36074e4da456c9e9bbb73611e8a372 /sys/kern
parent6b8c5a5e67931e028e3dc8aaee14961eda10dab8 (diff)
downloadFreeBSD-src-6967b9b093520d10a58f8d8ff6474706d19326b9.zip
FreeBSD-src-6967b9b093520d10a58f8d8ff6474706d19326b9.tar.gz
rearange some code that handles the thread taskqueue so that it is more
generic. Introduce a new define TASKQUEUE_DEFINE_THREAD that takes a single arg, which is the name of the queue. Document these changes.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_taskqueue.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index eaebd5d..a10e710 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -44,7 +44,6 @@ static void *taskqueue_giant_ih;
static void *taskqueue_ih;
static STAILQ_HEAD(taskqueue_list, taskqueue) taskqueue_queues;
static struct mtx taskqueue_queues_mutex;
-static struct proc *taskqueue_thread_proc;
struct taskqueue {
STAILQ_ENTRY(taskqueue) tq_link;
@@ -226,24 +225,30 @@ taskqueue_swi_giant_run(void *dummy)
taskqueue_run(taskqueue_swi_giant);
}
-static void
-taskqueue_thread_loop(void *dummy)
+void
+taskqueue_thread_loop(void *arg)
{
+ struct taskqueue **tqp, *tq;
- mtx_lock(&taskqueue_thread->tq_mutex);
+ tqp = arg;
+ tq = *tqp;
+ mtx_lock(&tq->tq_mutex);
for (;;) {
- taskqueue_run(taskqueue_thread);
- msleep(taskqueue_thread, &taskqueue_thread->tq_mutex, PWAIT,
- "-", 0);
+ taskqueue_run(tq);
+ msleep(tq, &tq->tq_mutex, PWAIT, "-", 0);
}
}
-static void
+void
taskqueue_thread_enqueue(void *context)
{
+ struct taskqueue **tqp, *tq;
+
+ tqp = context;
+ tq = *tqp;
- mtx_assert(&taskqueue_thread->tq_mutex, MA_OWNED);
- wakeup(taskqueue_thread);
+ mtx_assert(&tq->tq_mutex, MA_OWNED);
+ wakeup(tq);
}
TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, 0,
@@ -254,9 +259,7 @@ TASKQUEUE_DEFINE(swi_giant, taskqueue_swi_giant_enqueue, 0,
swi_add(NULL, "Giant task queue", taskqueue_swi_giant_run,
NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih));
-TASKQUEUE_DEFINE(thread, taskqueue_thread_enqueue, 0,
- kthread_create(taskqueue_thread_loop, NULL,
- &taskqueue_thread_proc, 0, 0, "taskqueue"));
+TASKQUEUE_DEFINE_THREAD(thread);
int
taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task)
OpenPOWER on IntegriCloud