1*3792Sakolb /* 2*3792Sakolb * CDDL HEADER START 3*3792Sakolb * 4*3792Sakolb * The contents of this file are subject to the terms of the 5*3792Sakolb * Common Development and Distribution License (the "License"). 6*3792Sakolb * You may not use this file except in compliance with the License. 7*3792Sakolb * 8*3792Sakolb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*3792Sakolb * or http://www.opensolaris.org/os/licensing. 10*3792Sakolb * See the License for the specific language governing permissions 11*3792Sakolb * and limitations under the License. 12*3792Sakolb * 13*3792Sakolb * When distributing Covered Code, include this CDDL HEADER in each 14*3792Sakolb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*3792Sakolb * If applicable, add the following below this CDDL HEADER, with the 16*3792Sakolb * fields enclosed by brackets "[]" replaced with your own identifying 17*3792Sakolb * information: Portions Copyright [yyyy] [name of copyright owner] 18*3792Sakolb * 19*3792Sakolb * CDDL HEADER END 20*3792Sakolb */ 21*3792Sakolb /* 22*3792Sakolb * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*3792Sakolb * Use is subject to license terms. 24*3792Sakolb */ 25*3792Sakolb 26*3792Sakolb #ifndef _SYS_WAITQ_H 27*3792Sakolb #define _SYS_WAITQ_H 28*3792Sakolb 29*3792Sakolb #pragma ident "%Z%%M% %I% %E% SMI" 30*3792Sakolb 31*3792Sakolb #ifdef __cplusplus 32*3792Sakolb extern "C" { 33*3792Sakolb #endif 34*3792Sakolb 35*3792Sakolb #ifdef _KERNEL 36*3792Sakolb 37*3792Sakolb #include <sys/types.h> 38*3792Sakolb #include <sys/machlock.h> 39*3792Sakolb #include <sys/thread.h> 40*3792Sakolb 41*3792Sakolb typedef struct waitq { 42*3792Sakolb disp_lock_t wq_lock; /* protects all fields */ 43*3792Sakolb kthread_t *wq_first; /* first thread on the queue */ 44*3792Sakolb int wq_count; /* number of threads on the queue */ 45*3792Sakolb boolean_t wq_blocked; /* True if threads can't be enqueued */ 46*3792Sakolb } waitq_t; 47*3792Sakolb 48*3792Sakolb extern void waitq_init(waitq_t *); 49*3792Sakolb extern void waitq_fini(waitq_t *); 50*3792Sakolb 51*3792Sakolb /* 52*3792Sakolb * Place the thread on the wait queue. An attempt to enqueue a thread onto a 53*3792Sakolb * blocked queue fails and returns zero. Successful enqueue returns non-zero 54*3792Sakolb * value. 55*3792Sakolb */ 56*3792Sakolb extern int waitq_enqueue(waitq_t *, kthread_t *); 57*3792Sakolb 58*3792Sakolb /* 59*3792Sakolb * Take thread off its wait queue and make it runnable. 60*3792Sakolb */ 61*3792Sakolb extern void waitq_setrun(kthread_t *t); 62*3792Sakolb 63*3792Sakolb /* 64*3792Sakolb * Change priority for the thread on wait queue. 65*3792Sakolb */ 66*3792Sakolb extern void waitq_change_pri(kthread_t *, pri_t); 67*3792Sakolb 68*3792Sakolb /* 69*3792Sakolb * Take the first thread off the wait queue and make it runnable. 70*3792Sakolb */ 71*3792Sakolb extern void waitq_runone(waitq_t *); 72*3792Sakolb 73*3792Sakolb /* 74*3792Sakolb * Return True if there are no threads on the queue. 75*3792Sakolb */ 76*3792Sakolb extern boolean_t waitq_isempty(waitq_t *); 77*3792Sakolb 78*3792Sakolb /* 79*3792Sakolb * Prevent and allow placing new threads on wait queue. 80*3792Sakolb */ 81*3792Sakolb extern void waitq_block(waitq_t *); 82*3792Sakolb extern void waitq_unblock(waitq_t *); 83*3792Sakolb 84*3792Sakolb #endif /* _KERNEL */ 85*3792Sakolb 86*3792Sakolb #ifdef __cplusplus 87*3792Sakolb } 88*3792Sakolb #endif 89*3792Sakolb 90*3792Sakolb #endif /* _SYS_WAITQ_H */ 91