summaryrefslogtreecommitdiffstats
path: root/lib/libzpool/taskq.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libzpool/taskq.c')
-rw-r--r--lib/libzpool/taskq.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/libzpool/taskq.c b/lib/libzpool/taskq.c
index 8db5d11c1..36c0ec7df 100644
--- a/lib/libzpool/taskq.c
+++ b/lib/libzpool/taskq.c
@@ -42,7 +42,7 @@ struct taskq {
krwlock_t tq_threadlock;
kcondvar_t tq_dispatch_cv;
kcondvar_t tq_wait_cv;
- thread_t *tq_threadlist;
+ kthread_t **tq_threadlist;
int tq_flags;
int tq_active;
int tq_nthreads;
@@ -154,7 +154,7 @@ taskq_wait(taskq_t *tq)
mutex_exit(&tq->tq_lock);
}
-static void *
+static void
taskq_thread(void *arg)
{
taskq_t *tq = arg;
@@ -183,7 +183,7 @@ taskq_thread(void *arg)
tq->tq_nthreads--;
cv_broadcast(&tq->tq_wait_cv);
mutex_exit(&tq->tq_lock);
- return (NULL);
+ thread_exit();
}
/*ARGSUSED*/
@@ -219,7 +219,7 @@ taskq_create(const char *name, int nthreads, pri_t pri,
tq->tq_maxalloc = maxalloc;
tq->tq_task.task_next = &tq->tq_task;
tq->tq_task.task_prev = &tq->tq_task;
- tq->tq_threadlist = kmem_alloc(nthreads * sizeof (thread_t), KM_SLEEP);
+ tq->tq_threadlist = kmem_alloc(nthreads*sizeof(kthread_t *), KM_SLEEP);
if (flags & TASKQ_PREPOPULATE) {
mutex_enter(&tq->tq_lock);
@@ -229,8 +229,8 @@ taskq_create(const char *name, int nthreads, pri_t pri,
}
for (t = 0; t < nthreads; t++)
- (void) thr_create(0, 0, taskq_thread,
- tq, THR_BOUND, &tq->tq_threadlist[t]);
+ VERIFY((tq->tq_threadlist[t] = thread_create(NULL, 0,
+ taskq_thread, tq, TS_RUN, NULL, 0, 0)) != NULL);
return (tq);
}
@@ -238,7 +238,6 @@ taskq_create(const char *name, int nthreads, pri_t pri,
void
taskq_destroy(taskq_t *tq)
{
- int t;
int nthreads = tq->tq_nthreads;
taskq_wait(tq);
@@ -259,10 +258,7 @@ taskq_destroy(taskq_t *tq)
mutex_exit(&tq->tq_lock);
- for (t = 0; t < nthreads; t++)
- (void) thr_join(tq->tq_threadlist[t], NULL, NULL);
-
- kmem_free(tq->tq_threadlist, nthreads * sizeof (thread_t));
+ kmem_free(tq->tq_threadlist, nthreads * sizeof (kthread_t *));
rw_destroy(&tq->tq_threadlock);
mutex_destroy(&tq->tq_lock);
@@ -274,7 +270,7 @@ taskq_destroy(taskq_t *tq)
}
int
-taskq_member(taskq_t *tq, void *t)
+taskq_member(taskq_t *tq, kthread_t *t)
{
int i;
@@ -282,7 +278,7 @@ taskq_member(taskq_t *tq, void *t)
return (1);
for (i = 0; i < tq->tq_nthreads; i++)
- if (tq->tq_threadlist[i] == (thread_t)(uintptr_t)t)
+ if (tq->tq_threadlist[i] == t)
return (1);
return (0);