4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 #ifndef _SYS_TASKQ_IMPL_H
30 #define _SYS_TASKQ_IMPL_H
32 #pragma ident "@(#)taskq_impl.h 1.6 05/06/08 SMI"
34 #include <sys/mutex.h>
35 #include <sys/rwlock.h>
36 #include <sys/condvar.h>
37 #include <sys/taskq.h>
43 typedef struct taskq_bucket taskq_bucket_t;
45 typedef struct taskq_ent {
46 struct taskq_ent *tqent_next;
47 struct taskq_ent *tqent_prev;
48 task_func_t *tqent_func;
50 taskq_bucket_t *tqent_bucket;
51 kthread_t *tqent_thread;
56 * Taskq Statistics fields are not protected by any locks.
58 typedef struct tqstat {
61 uint_t tqs_overflow; /* no threads to allocate */
62 uint_t tqs_tcreates; /* threads created */
63 uint_t tqs_tdeaths; /* threads died */
64 uint_t tqs_maxthreads; /* max # of alive threads */
65 uint_t tqs_nomem; /* # of times there were no memory */
66 uint_t tqs_disptcreates;
70 * Per-CPU hash bucket manages taskq_bent_t structures using freelist.
73 kmutex_t tqbucket_lock;
74 taskq_t *tqbucket_taskq; /* Enclosing taskq */
75 taskq_ent_t tqbucket_freelist;
76 uint_t tqbucket_nalloc; /* # of allocated entries */
77 uint_t tqbucket_nfree; /* # of free entries */
78 kcondvar_t tqbucket_cv;
79 ushort_t tqbucket_flags;
80 hrtime_t tqbucket_totaltime;
81 tqstat_t tqbucket_stat;
87 #define TQBUCKET_CLOSE 0x01
88 #define TQBUCKET_SUSPEND 0x02
91 * taskq implementation flags: bit range 16-31
93 #define TASKQ_ACTIVE 0x00010000
94 #define TASKQ_SUSPENDED 0x00020000
95 #define TASKQ_NOINSTANCE 0x00040000
98 char tq_name[TASKQ_NAMELEN + 1];
100 krwlock_t tq_threadlock;
101 kcondvar_t tq_dispatch_cv;
102 kcondvar_t tq_wait_cv;
109 taskq_ent_t *tq_freelist;
112 pri_t tq_pri; /* Scheduling priority */
113 taskq_bucket_t *tq_buckets; /* Per-cpu array of buckets */
114 uint_t tq_nbuckets; /* # of buckets (2^n) */
116 kthread_t *_tq_thread;
117 kthread_t **_tq_threadlist;
122 hrtime_t tq_totaltime; /* Time spent processing tasks */
123 int tq_tasks; /* Total # of tasks posted */
124 int tq_executed; /* Total # of tasks executed */
125 int tq_maxtasks; /* Max number of tasks in the queue */
130 #define tq_thread tq_thr._tq_thread
131 #define tq_threadlist tq_thr._tq_threadlist
137 #endif /* _SYS_TASKQ_IMPL_H */