10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 511066Srafael.vanoni@sun.com * Common Development and Distribution License (the "License"). 611066Srafael.vanoni@sun.com * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 2211066Srafael.vanoni@sun.com * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * condvar.h: 280Sstevel@tonic-gate * 290Sstevel@tonic-gate * definitions for thread synchronization primitives: condition variables 300Sstevel@tonic-gate * This is the public part of the interface to condition variables. The 310Sstevel@tonic-gate * private (implementation-specific) part is in <arch>/sys/condvar_impl.h. 320Sstevel@tonic-gate */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifndef _SYS_CONDVAR_H 350Sstevel@tonic-gate #define _SYS_CONDVAR_H 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifndef _ASM 380Sstevel@tonic-gate #include <sys/types.h> 390Sstevel@tonic-gate #include <sys/time.h> 400Sstevel@tonic-gate #ifdef _KERNEL 410Sstevel@tonic-gate #include <sys/mutex.h> 420Sstevel@tonic-gate #endif /* _KERNEL */ 430Sstevel@tonic-gate #endif /* _ASM */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate #ifdef __cplusplus 460Sstevel@tonic-gate extern "C" { 470Sstevel@tonic-gate #endif 480Sstevel@tonic-gate 490Sstevel@tonic-gate #ifndef _ASM 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* 520Sstevel@tonic-gate * Condtion variables. 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate typedef struct _kcondvar { 560Sstevel@tonic-gate ushort_t _opaque; 570Sstevel@tonic-gate } kcondvar_t; 580Sstevel@tonic-gate 590Sstevel@tonic-gate typedef enum { 600Sstevel@tonic-gate CV_DEFAULT, 610Sstevel@tonic-gate CV_DRIVER 620Sstevel@tonic-gate } kcv_type_t; 630Sstevel@tonic-gate 64*11144Srafael.vanoni@sun.com #if defined(_KERNEL) 65*11144Srafael.vanoni@sun.com 6611066Srafael.vanoni@sun.com /* 6711066Srafael.vanoni@sun.com * Time resolution values used in cv_reltimedwait() and cv_reltimedwait_sig() 6811066Srafael.vanoni@sun.com * to specify how accurately a relative timeout must expire - if it can be 6911066Srafael.vanoni@sun.com * anticipated or deferred. 7011066Srafael.vanoni@sun.com */ 71*11144Srafael.vanoni@sun.com typedef enum { 7211066Srafael.vanoni@sun.com TR_NANOSEC, 7311066Srafael.vanoni@sun.com TR_MICROSEC, 7411066Srafael.vanoni@sun.com TR_MILLISEC, 7511066Srafael.vanoni@sun.com TR_SEC, 7611066Srafael.vanoni@sun.com TR_CLOCK_TICK, 7711066Srafael.vanoni@sun.com TR_COUNT 78*11144Srafael.vanoni@sun.com } time_res_t; 7911066Srafael.vanoni@sun.com 8011066Srafael.vanoni@sun.com extern time_res_t time_res[]; 8111066Srafael.vanoni@sun.com 8211066Srafael.vanoni@sun.com #define TIME_RES_VALID(tr) (tr >= TR_NANOSEC && tr < TR_COUNT) 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * condition variable function prototypes 860Sstevel@tonic-gate */ 870Sstevel@tonic-gate 880Sstevel@tonic-gate extern void cv_init(kcondvar_t *, char *, kcv_type_t, void *); 890Sstevel@tonic-gate extern void cv_destroy(kcondvar_t *); 900Sstevel@tonic-gate extern void cv_wait(kcondvar_t *, kmutex_t *); 910Sstevel@tonic-gate extern void cv_wait_stop(kcondvar_t *, kmutex_t *, int); 920Sstevel@tonic-gate extern clock_t cv_timedwait(kcondvar_t *, kmutex_t *, clock_t); 9311066Srafael.vanoni@sun.com extern clock_t cv_reltimedwait(kcondvar_t *, kmutex_t *, clock_t, time_res_t); 940Sstevel@tonic-gate extern int cv_wait_sig(kcondvar_t *, kmutex_t *); 950Sstevel@tonic-gate extern clock_t cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t); 9611066Srafael.vanoni@sun.com extern clock_t cv_reltimedwait_sig(kcondvar_t *, kmutex_t *, clock_t, 9711066Srafael.vanoni@sun.com time_res_t); 980Sstevel@tonic-gate extern int cv_wait_sig_swap(kcondvar_t *, kmutex_t *); 990Sstevel@tonic-gate extern int cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *); 1000Sstevel@tonic-gate extern void cv_signal(kcondvar_t *); 1010Sstevel@tonic-gate extern void cv_broadcast(kcondvar_t *); 1024123Sdm120769 extern int cv_waituntil_sig(kcondvar_t *, kmutex_t *, timestruc_t *, int); 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate #endif /* defined(_KERNEL) */ 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate #endif /* _ASM */ 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate #ifdef __cplusplus 1090Sstevel@tonic-gate } 1100Sstevel@tonic-gate #endif 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate #endif /* _SYS_CONDVAR_H */ 113