diff options
author | Scott Long <scottl@FreeBSD.org> | 2006-01-14 01:55:24 +0000 |
---|---|---|
committer | Scott Long <scottl@FreeBSD.org> | 2006-01-14 01:55:24 +0000 |
commit | 0f92108d32d89a5e9f1ec37a83ec13a85c616840 (patch) | |
tree | f5229c8522204692d0896701c0159d45163983de /sys/sys/taskqueue.h | |
parent | c8250f086b52c3a495186b5c2d425eb77fa6bbc2 (diff) | |
download | src-0f92108d32d89a5e9f1ec37a83ec13a85c616840.tar.gz src-0f92108d32d89a5e9f1ec37a83ec13a85c616840.zip |
Add the following to the taskqueue api:
taskqueue_start_threads(struct taskqueue **, int count, int pri,
const char *name, ...);
This allows the creation of 1 or more threads that will service a single
taskqueue. Also rework the taskqueue_create() API to remove the API change
that was introduced a while back. Creating a taskqueue doesn't rely on
the presence of a process structure, and the proc mechanics are much better
encapsulated in taskqueue_start_threads(). Also clean up the
taskqueue_terminate() and taskqueue_free() functions to safely drain
pending tasks and remove all associated threads.
The TASKQUEUE_DEFINE and TASKQUEUE_DEFINE_THREAD macros have been changed
to use the new API, but drivers compiled against the old definitions will
still work. Thus, recompiling drivers is not a strict requirement.
Notes
Notes:
svn path=/head/; revision=154333
Diffstat (limited to 'sys/sys/taskqueue.h')
-rw-r--r-- | sys/sys/taskqueue.h | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h index 59ac30988793..6d6d9ad6997e 100644 --- a/sys/sys/taskqueue.h +++ b/sys/sys/taskqueue.h @@ -50,7 +50,9 @@ typedef void (*taskqueue_enqueue_fn)(void *context); struct proc; struct taskqueue *taskqueue_create(const char *name, int mflags, taskqueue_enqueue_fn enqueue, - void *context, struct proc **); + void *context); +int taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, + const char *name, ...) __printflike(4, 5); int taskqueue_enqueue(struct taskqueue *queue, struct task *task); void taskqueue_drain(struct taskqueue *queue, struct task *task); struct taskqueue *taskqueue_find(const char *name); @@ -89,10 +91,8 @@ struct taskqueue *taskqueue_##name; \ static void \ taskqueue_define_##name(void *arg) \ { \ - static struct proc *taskqueue_##name##_proc; \ taskqueue_##name = \ - taskqueue_create(#name, M_NOWAIT, (enqueue), (context), \ - &taskqueue_##name##_proc); \ + taskqueue_create(#name, M_NOWAIT, (enqueue), (context)); \ init; \ } \ \ @@ -102,8 +102,8 @@ SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND, \ struct __hack #define TASKQUEUE_DEFINE_THREAD(name) \ TASKQUEUE_DEFINE(name, taskqueue_thread_enqueue, &taskqueue_##name, \ - kthread_create(taskqueue_thread_loop, &taskqueue_##name, \ - &taskqueue_##name##_proc, 0, 0, #name " taskq")) + taskqueue_start_threads(&taskqueue_##name, 1, PWAIT, \ + "%s taskq", #name)) /* * Define and initialise a global taskqueue that uses spin mutexes. @@ -115,10 +115,9 @@ struct taskqueue *taskqueue_##name; \ static void \ taskqueue_define_##name(void *arg) \ { \ - static struct proc *taskqueue_##name##_proc; \ taskqueue_##name = \ - taskqueue_create_fast(#name, M_NOWAIT, (enqueue), (context),\ - &taskqueue_##name##_proc); \ + taskqueue_create_fast(#name, M_NOWAIT, (enqueue), \ + (context)); \ init; \ } \ \ @@ -128,9 +127,8 @@ SYSINIT(taskqueue_##name, SI_SUB_CONFIGURE, SI_ORDER_SECOND, \ struct __hack #define TASKQUEUE_FAST_DEFINE_THREAD(name) \ TASKQUEUE_FAST_DEFINE(name, taskqueue_thread_enqueue, \ - &taskqueue_##name, kthread_create(taskqueue_thread_loop, \ - &taskqueue_##name, &taskqueue_##name##_proc, 0, 0, \ - #name " fast taskq")) + &taskqueue_##name, taskqueue_start_threads(&taskqueue_##name \ + 1, PWAIT, "%s taskq", #name)) /* * These queues are serviced by software interrupt handlers. To enqueue @@ -156,6 +154,6 @@ TASKQUEUE_DECLARE(fast); int taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task); struct taskqueue *taskqueue_create_fast(const char *name, int mflags, taskqueue_enqueue_fn enqueue, - void *context, struct proc **); + void *context); #endif /* !_SYS_TASKQUEUE_H_ */ |