diff options
Diffstat (limited to 'usr/src')
| -rw-r--r-- | usr/src/lib/libfakekernel/common/mapfile-vers | 2 | ||||
| -rw-r--r-- | usr/src/lib/libfakekernel/common/taskq.c | 13 | ||||
| -rw-r--r-- | usr/src/uts/common/os/taskq.c | 21 | ||||
| -rw-r--r-- | usr/src/uts/common/sys/taskq.h | 2 |
4 files changed, 38 insertions, 0 deletions
diff --git a/usr/src/lib/libfakekernel/common/mapfile-vers b/usr/src/lib/libfakekernel/common/mapfile-vers index 4b562302ba..578301be86 100644 --- a/usr/src/lib/libfakekernel/common/mapfile-vers +++ b/usr/src/lib/libfakekernel/common/mapfile-vers @@ -12,6 +12,7 @@ # # Copyright 2015 Nexenta Systems, Inc. All rights reserved. # Copyright 2017 RackTop Systems. +# Copyright 2018, Joyent, Inc. # # @@ -202,6 +203,7 @@ SYMBOL_VERSION SUNWprivate_1.1 { taskq_destroy; taskq_dispatch; taskq_dispatch_ent; + taskq_empty; taskq_member; taskq_wait; diff --git a/usr/src/lib/libfakekernel/common/taskq.c b/usr/src/lib/libfakekernel/common/taskq.c index d9908485e2..1d04326829 100644 --- a/usr/src/lib/libfakekernel/common/taskq.c +++ b/usr/src/lib/libfakekernel/common/taskq.c @@ -26,6 +26,7 @@ * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright 2017 RackTop Systems. + * Copyright 2018, Joyent, Inc. */ #include <sys/taskq_impl.h> @@ -212,6 +213,18 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags, mutex_exit(&tq->tq_lock); } +boolean_t +taskq_empty(taskq_t *tq) +{ + boolean_t rv; + + mutex_enter(&tq->tq_lock); + rv = (tq->tq_task.tqent_next == &tq->tq_task) && (tq->tq_active == 0); + mutex_exit(&tq->tq_lock); + + return (rv); +} + void taskq_wait(taskq_t *tq) { diff --git a/usr/src/uts/common/os/taskq.c b/usr/src/uts/common/os/taskq.c index 814b738581..1fe93e9735 100644 --- a/usr/src/uts/common/os/taskq.c +++ b/usr/src/uts/common/os/taskq.c @@ -26,6 +26,7 @@ /* * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2017 by Delphix. All rights reserved. + * Copyright 2018, Joyent, Inc. */ /* @@ -200,6 +201,10 @@ * may safely modify or free this memory, once it is called.) * Note that the taskq framework will NOT free this memory. * + * boolean_t taskq_empty(tq) + * + * Queries if there are tasks pending on the queue. + * * void taskq_wait(tq): * * Waits for all previously scheduled tasks to complete. @@ -1320,6 +1325,22 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags, } /* + * Allow our caller to ask if there are tasks pending on the queue. + */ +boolean_t +taskq_empty(taskq_t *tq) +{ + boolean_t rv; + + ASSERT3P(tq, !=, curthread->t_taskq); + mutex_enter(&tq->tq_lock); + rv = (tq->tq_task.tqent_next == &tq->tq_task) && (tq->tq_active == 0); + mutex_exit(&tq->tq_lock); + + return (rv); +} + +/* * Wait for all pending tasks to complete. * Calling taskq_wait from a task will cause deadlock. */ diff --git a/usr/src/uts/common/sys/taskq.h b/usr/src/uts/common/sys/taskq.h index 7548149ef6..87c68d22f6 100644 --- a/usr/src/uts/common/sys/taskq.h +++ b/usr/src/uts/common/sys/taskq.h @@ -23,6 +23,7 @@ * Use is subject to license terms. * * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2018, Joyent, Inc. */ #ifndef _SYS_TASKQ_H @@ -80,6 +81,7 @@ extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t); extern void nulltask(void *); extern void taskq_destroy(taskq_t *); extern void taskq_wait(taskq_t *); +extern boolean_t taskq_empty(taskq_t *); extern void taskq_suspend(taskq_t *); extern int taskq_suspended(taskq_t *); extern void taskq_resume(taskq_t *); |
