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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_TASKQ_IMPL_H
28 #define _SYS_TASKQ_IMPL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/taskq.h>
34 #include <sys/kstat.h>
40 typedef struct taskq_bucket taskq_bucket_t
;
42 typedef struct taskq_ent
{
43 struct taskq_ent
*tqent_next
;
44 struct taskq_ent
*tqent_prev
;
45 task_func_t
*tqent_func
;
47 taskq_bucket_t
*tqent_bucket
;
48 kthread_t
*tqent_thread
;
53 * Taskq Statistics fields are not protected by any locks.
55 typedef struct tqstat
{
58 uint_t tqs_overflow
; /* no threads to allocate */
59 uint_t tqs_tcreates
; /* threads created */
60 uint_t tqs_tdeaths
; /* threads died */
61 uint_t tqs_maxthreads
; /* max # of alive threads */
62 uint_t tqs_nomem
; /* # of times there were no memory */
63 uint_t tqs_disptcreates
;
67 * Per-CPU hash bucket manages taskq_bent_t structures using freelist.
70 kmutex_t tqbucket_lock
;
71 taskq_t
*tqbucket_taskq
; /* Enclosing taskq */
72 taskq_ent_t tqbucket_freelist
;
73 uint_t tqbucket_nalloc
; /* # of allocated entries */
74 uint_t tqbucket_nfree
; /* # of free entries */
75 kcondvar_t tqbucket_cv
;
76 ushort_t tqbucket_flags
;
77 hrtime_t tqbucket_totaltime
;
78 tqstat_t tqbucket_stat
;
84 #define TQBUCKET_CLOSE 0x01
85 #define TQBUCKET_SUSPEND 0x02
88 * taskq implementation flags: bit range 16-31
90 #define TASKQ_ACTIVE 0x00010000
91 #define TASKQ_SUSPENDED 0x00020000
92 #define TASKQ_NOINSTANCE 0x00040000
95 char tq_name
[TASKQ_NAMELEN
+ 1];
97 krwlock_t tq_threadlock
;
98 kcondvar_t tq_dispatch_cv
;
99 kcondvar_t tq_wait_cv
;
106 taskq_ent_t
*tq_freelist
;
109 pri_t tq_pri
; /* Scheduling priority */
110 taskq_bucket_t
*tq_buckets
; /* Per-cpu array of buckets */
112 uint_t tq_nbuckets
; /* # of buckets (2^n) */
114 kthread_t
*_tq_thread
;
115 kthread_t
**_tq_threadlist
;
120 kstat_t
*tq_kstat
; /* Exported statistics */
121 hrtime_t tq_totaltime
; /* Time spent processing tasks */
122 int tq_tasks
; /* Total # of tasks posted */
123 int tq_executed
; /* Total # of tasks executed */
124 int tq_maxtasks
; /* Max number of tasks in the queue */
129 #define tq_thread tq_thr._tq_thread
130 #define tq_threadlist tq_thr._tq_threadlist
136 #endif /* _SYS_TASKQ_IMPL_H */