Home | History | Annotate | Line # | Download | only in kern
kern_condvar.c revision 1.16.4.2
      1  1.16.4.2  yamt /*	$NetBSD: kern_condvar.c,v 1.16.4.2 2009/05/04 08:13:46 yamt Exp $	*/
      2       1.2    ad 
      3       1.2    ad /*-
      4      1.15    ad  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
      5       1.2    ad  * All rights reserved.
      6       1.2    ad  *
      7       1.2    ad  * This code is derived from software contributed to The NetBSD Foundation
      8       1.2    ad  * by Andrew Doran.
      9       1.2    ad  *
     10       1.2    ad  * Redistribution and use in source and binary forms, with or without
     11       1.2    ad  * modification, are permitted provided that the following conditions
     12       1.2    ad  * are met:
     13       1.2    ad  * 1. Redistributions of source code must retain the above copyright
     14       1.2    ad  *    notice, this list of conditions and the following disclaimer.
     15       1.2    ad  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.2    ad  *    notice, this list of conditions and the following disclaimer in the
     17       1.2    ad  *    documentation and/or other materials provided with the distribution.
     18       1.2    ad  *
     19       1.2    ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.2    ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.2    ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.2    ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.2    ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.2    ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.2    ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.2    ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.2    ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.2    ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.2    ad  * POSSIBILITY OF SUCH DAMAGE.
     30       1.2    ad  */
     31       1.2    ad 
     32       1.2    ad /*
     33  1.16.4.2  yamt  * Kernel condition variable implementation.
     34       1.2    ad  */
     35       1.2    ad 
     36       1.2    ad #include <sys/cdefs.h>
     37  1.16.4.2  yamt __KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.16.4.2 2009/05/04 08:13:46 yamt Exp $");
     38       1.2    ad 
     39       1.2    ad #include <sys/param.h>
     40       1.2    ad #include <sys/proc.h>
     41       1.2    ad #include <sys/sched.h>
     42       1.2    ad #include <sys/systm.h>
     43       1.2    ad #include <sys/condvar.h>
     44       1.2    ad #include <sys/sleepq.h>
     45  1.16.4.2  yamt #include <sys/lockdebug.h>
     46  1.16.4.2  yamt #include <sys/cpu.h>
     47  1.16.4.2  yamt 
     48  1.16.4.2  yamt #include <uvm/uvm_extern.h>
     49  1.16.4.2  yamt 
     50  1.16.4.2  yamt /*
     51  1.16.4.2  yamt  * Accessors for the private contents of the kcondvar_t data type.
     52  1.16.4.2  yamt  *
     53  1.16.4.2  yamt  *	cv_opaque[0]	sleepq...
     54  1.16.4.2  yamt  *	cv_opaque[1]	...pointers
     55  1.16.4.2  yamt  *	cv_opaque[2]	description for ps(1)
     56  1.16.4.2  yamt  *
     57  1.16.4.2  yamt  * cv_opaque[0..1] is protected by the interlock passed to cv_wait() (enqueue
     58  1.16.4.2  yamt  * only), and the sleep queue lock acquired with sleeptab_lookup() (enqueue
     59  1.16.4.2  yamt  * and dequeue).
     60  1.16.4.2  yamt  *
     61  1.16.4.2  yamt  * cv_opaque[2] (the wmesg) is static and does not change throughout the life
     62  1.16.4.2  yamt  * of the CV.
     63  1.16.4.2  yamt  */
     64  1.16.4.2  yamt #define	CV_SLEEPQ(cv)		((sleepq_t *)(cv)->cv_opaque)
     65  1.16.4.2  yamt #define	CV_WMESG(cv)		((const char *)(cv)->cv_opaque[2])
     66  1.16.4.2  yamt #define	CV_SET_WMESG(cv, v) 	(cv)->cv_opaque[2] = __UNCONST(v)
     67  1.16.4.2  yamt 
     68  1.16.4.2  yamt #define	CV_DEBUG_P(cv)	(CV_WMESG(cv) != nodebug)
     69  1.16.4.2  yamt #define	CV_RA		((uintptr_t)__builtin_return_address(0))
     70       1.2    ad 
     71      1.16    ad static u_int	cv_unsleep(lwp_t *, bool);
     72  1.16.4.2  yamt static void	cv_wakeup_one(kcondvar_t *);
     73  1.16.4.2  yamt static void	cv_wakeup_all(kcondvar_t *);
     74       1.2    ad 
     75      1.10    ad static syncobj_t cv_syncobj = {
     76       1.2    ad 	SOBJ_SLEEPQ_SORTED,
     77       1.2    ad 	cv_unsleep,
     78      1.14    ad 	sleepq_changepri,
     79       1.4  yamt 	sleepq_lendpri,
     80       1.4  yamt 	syncobj_noowner,
     81       1.2    ad };
     82       1.2    ad 
     83  1.16.4.2  yamt lockops_t cv_lockops = {
     84  1.16.4.2  yamt 	"Condition variable",
     85  1.16.4.2  yamt 	LOCKOPS_CV,
     86  1.16.4.2  yamt 	NULL
     87  1.16.4.2  yamt };
     88  1.16.4.2  yamt 
     89      1.10    ad static const char deadcv[] = "deadcv";
     90  1.16.4.2  yamt static const char nodebug[] = "nodebug";
     91      1.10    ad 
     92       1.2    ad /*
     93       1.2    ad  * cv_init:
     94       1.2    ad  *
     95       1.2    ad  *	Initialize a condition variable for use.
     96       1.2    ad  */
     97       1.2    ad void
     98       1.2    ad cv_init(kcondvar_t *cv, const char *wmesg)
     99       1.2    ad {
    100  1.16.4.2  yamt #ifdef LOCKDEBUG
    101  1.16.4.2  yamt 	bool dodebug;
    102       1.2    ad 
    103  1.16.4.2  yamt 	dodebug = LOCKDEBUG_ALLOC(cv, &cv_lockops,
    104  1.16.4.2  yamt 	    (uintptr_t)__builtin_return_address(0));
    105  1.16.4.2  yamt 	if (!dodebug) {
    106  1.16.4.2  yamt 		/* XXX This will break vfs_lockf. */
    107  1.16.4.2  yamt 		wmesg = nodebug;
    108  1.16.4.2  yamt 	}
    109  1.16.4.2  yamt #endif
    110       1.2    ad 	KASSERT(wmesg != NULL);
    111  1.16.4.2  yamt 	CV_SET_WMESG(cv, wmesg);
    112  1.16.4.2  yamt 	sleepq_init(CV_SLEEPQ(cv));
    113       1.2    ad }
    114       1.2    ad 
    115       1.2    ad /*
    116       1.2    ad  * cv_destroy:
    117       1.2    ad  *
    118       1.2    ad  *	Tear down a condition variable.
    119       1.2    ad  */
    120       1.2    ad void
    121       1.2    ad cv_destroy(kcondvar_t *cv)
    122       1.2    ad {
    123       1.2    ad 
    124  1.16.4.2  yamt 	LOCKDEBUG_FREE(CV_DEBUG_P(cv), cv);
    125       1.2    ad #ifdef DIAGNOSTIC
    126      1.15    ad 	KASSERT(cv_is_valid(cv));
    127  1.16.4.2  yamt 	CV_SET_WMESG(cv, deadcv);
    128       1.2    ad #endif
    129       1.2    ad }
    130       1.2    ad 
    131       1.2    ad /*
    132       1.2    ad  * cv_enter:
    133       1.2    ad  *
    134       1.2    ad  *	Look up and lock the sleep queue corresponding to the given
    135       1.2    ad  *	condition variable, and increment the number of waiters.
    136       1.2    ad  */
    137  1.16.4.2  yamt static inline void
    138       1.6    ad cv_enter(kcondvar_t *cv, kmutex_t *mtx, lwp_t *l)
    139       1.2    ad {
    140       1.2    ad 	sleepq_t *sq;
    141  1.16.4.2  yamt 	kmutex_t *mp;
    142       1.2    ad 
    143      1.15    ad 	KASSERT(cv_is_valid(cv));
    144  1.16.4.2  yamt 	KASSERT(!cpu_intr_p());
    145      1.14    ad 	KASSERT((l->l_pflag & LP_INTR) == 0 || panicstr != NULL);
    146       1.2    ad 
    147  1.16.4.2  yamt 	LOCKDEBUG_LOCKED(CV_DEBUG_P(cv), cv, mtx, CV_RA, 0);
    148  1.16.4.2  yamt 
    149      1.14    ad 	l->l_kpriority = true;
    150  1.16.4.2  yamt 	mp = sleepq_hashlock(cv);
    151  1.16.4.2  yamt 	sq = CV_SLEEPQ(cv);
    152  1.16.4.2  yamt 	sleepq_enter(sq, l, mp);
    153  1.16.4.2  yamt 	sleepq_enqueue(sq, cv, CV_WMESG(cv), &cv_syncobj);
    154       1.2    ad 	mutex_exit(mtx);
    155  1.16.4.2  yamt 	KASSERT(cv_has_waiters(cv));
    156       1.2    ad }
    157       1.2    ad 
    158       1.2    ad /*
    159       1.6    ad  * cv_exit:
    160       1.6    ad  *
    161       1.6    ad  *	After resuming execution, check to see if we have been restarted
    162       1.6    ad  *	as a result of cv_signal().  If we have, but cannot take the
    163       1.6    ad  *	wakeup (because of eg a pending Unix signal or timeout) then try
    164       1.6    ad  *	to ensure that another LWP sees it.  This is necessary because
    165       1.6    ad  *	there may be multiple waiters, and at least one should take the
    166       1.6    ad  *	wakeup if possible.
    167       1.6    ad  */
    168       1.6    ad static inline int
    169       1.6    ad cv_exit(kcondvar_t *cv, kmutex_t *mtx, lwp_t *l, const int error)
    170       1.6    ad {
    171       1.6    ad 
    172       1.6    ad 	mutex_enter(mtx);
    173  1.16.4.2  yamt 	if (__predict_false(error != 0))
    174       1.6    ad 		cv_signal(cv);
    175       1.6    ad 
    176  1.16.4.2  yamt 	LOCKDEBUG_UNLOCKED(CV_DEBUG_P(cv), cv, CV_RA, 0);
    177      1.15    ad 	KASSERT(cv_is_valid(cv));
    178      1.10    ad 
    179       1.6    ad 	return error;
    180       1.6    ad }
    181       1.6    ad 
    182       1.6    ad /*
    183       1.2    ad  * cv_unsleep:
    184       1.2    ad  *
    185       1.2    ad  *	Remove an LWP from the condition variable and sleep queue.  This
    186       1.2    ad  *	is called when the LWP has not been awoken normally but instead
    187       1.2    ad  *	interrupted: for example, when a signal is received.  Must be
    188       1.2    ad  *	called with the LWP locked, and must return it unlocked.
    189       1.2    ad  */
    190      1.16    ad static u_int
    191      1.16    ad cv_unsleep(lwp_t *l, bool cleanup)
    192       1.2    ad {
    193      1.10    ad 	kcondvar_t *cv;
    194       1.2    ad 
    195      1.15    ad 	cv = (kcondvar_t *)(uintptr_t)l->l_wchan;
    196      1.15    ad 
    197  1.16.4.2  yamt 	KASSERT(l->l_wchan == (wchan_t)cv);
    198  1.16.4.2  yamt 	KASSERT(l->l_sleepq == CV_SLEEPQ(cv));
    199      1.15    ad 	KASSERT(cv_is_valid(cv));
    200  1.16.4.2  yamt 	KASSERT(cv_has_waiters(cv));
    201       1.2    ad 
    202      1.16    ad 	return sleepq_unsleep(l, cleanup);
    203       1.2    ad }
    204       1.2    ad 
    205       1.2    ad /*
    206       1.2    ad  * cv_wait:
    207       1.2    ad  *
    208       1.2    ad  *	Wait non-interruptably on a condition variable until awoken.
    209       1.2    ad  */
    210       1.2    ad void
    211       1.2    ad cv_wait(kcondvar_t *cv, kmutex_t *mtx)
    212       1.2    ad {
    213       1.6    ad 	lwp_t *l = curlwp;
    214       1.2    ad 
    215       1.8  yamt 	KASSERT(mutex_owned(mtx));
    216       1.2    ad 
    217  1.16.4.2  yamt 	cv_enter(cv, mtx, l);
    218       1.8  yamt 	(void)sleepq_block(0, false);
    219       1.6    ad 	(void)cv_exit(cv, mtx, l, 0);
    220       1.2    ad }
    221       1.2    ad 
    222       1.2    ad /*
    223       1.2    ad  * cv_wait_sig:
    224       1.2    ad  *
    225       1.2    ad  *	Wait on a condition variable until a awoken or a signal is received.
    226       1.2    ad  *	Will also return early if the process is exiting.  Returns zero if
    227       1.2    ad  *	awoken normallly, ERESTART if a signal was received and the system
    228       1.2    ad  *	call is restartable, or EINTR otherwise.
    229       1.2    ad  */
    230       1.2    ad int
    231       1.2    ad cv_wait_sig(kcondvar_t *cv, kmutex_t *mtx)
    232       1.2    ad {
    233       1.6    ad 	lwp_t *l = curlwp;
    234       1.2    ad 	int error;
    235       1.2    ad 
    236       1.8  yamt 	KASSERT(mutex_owned(mtx));
    237       1.2    ad 
    238  1.16.4.2  yamt 	cv_enter(cv, mtx, l);
    239       1.8  yamt 	error = sleepq_block(0, true);
    240       1.6    ad 	return cv_exit(cv, mtx, l, error);
    241       1.2    ad }
    242       1.2    ad 
    243       1.2    ad /*
    244       1.2    ad  * cv_timedwait:
    245       1.2    ad  *
    246       1.2    ad  *	Wait on a condition variable until awoken or the specified timeout
    247       1.2    ad  *	expires.  Returns zero if awoken normally or EWOULDBLOCK if the
    248       1.2    ad  *	timeout expired.
    249       1.2    ad  */
    250       1.2    ad int
    251       1.2    ad cv_timedwait(kcondvar_t *cv, kmutex_t *mtx, int timo)
    252       1.2    ad {
    253       1.6    ad 	lwp_t *l = curlwp;
    254       1.2    ad 	int error;
    255       1.2    ad 
    256       1.8  yamt 	KASSERT(mutex_owned(mtx));
    257       1.2    ad 
    258  1.16.4.2  yamt 	cv_enter(cv, mtx, l);
    259       1.8  yamt 	error = sleepq_block(timo, false);
    260       1.6    ad 	return cv_exit(cv, mtx, l, error);
    261       1.2    ad }
    262       1.2    ad 
    263       1.2    ad /*
    264       1.2    ad  * cv_timedwait_sig:
    265       1.2    ad  *
    266       1.2    ad  *	Wait on a condition variable until a timeout expires, awoken or a
    267       1.2    ad  *	signal is received.  Will also return early if the process is
    268       1.2    ad  *	exiting.  Returns zero if awoken normallly, EWOULDBLOCK if the
    269       1.2    ad  *	timeout expires, ERESTART if a signal was received and the system
    270       1.2    ad  *	call is restartable, or EINTR otherwise.
    271       1.2    ad  */
    272       1.2    ad int
    273       1.2    ad cv_timedwait_sig(kcondvar_t *cv, kmutex_t *mtx, int timo)
    274       1.2    ad {
    275       1.6    ad 	lwp_t *l = curlwp;
    276       1.2    ad 	int error;
    277       1.2    ad 
    278       1.8  yamt 	KASSERT(mutex_owned(mtx));
    279       1.2    ad 
    280  1.16.4.2  yamt 	cv_enter(cv, mtx, l);
    281       1.8  yamt 	error = sleepq_block(timo, true);
    282       1.6    ad 	return cv_exit(cv, mtx, l, error);
    283       1.2    ad }
    284       1.2    ad 
    285       1.2    ad /*
    286       1.2    ad  * cv_signal:
    287       1.2    ad  *
    288       1.2    ad  *	Wake the highest priority LWP waiting on a condition variable.
    289       1.2    ad  *	Must be called with the interlocking mutex held.
    290       1.2    ad  */
    291       1.2    ad void
    292       1.2    ad cv_signal(kcondvar_t *cv)
    293       1.2    ad {
    294  1.16.4.2  yamt 
    295  1.16.4.2  yamt 	/* LOCKDEBUG_WAKEUP(CV_DEBUG_P(cv), cv, CV_RA); */
    296  1.16.4.2  yamt 	KASSERT(cv_is_valid(cv));
    297  1.16.4.2  yamt 
    298  1.16.4.2  yamt 	if (__predict_false(!TAILQ_EMPTY(CV_SLEEPQ(cv))))
    299  1.16.4.2  yamt 		cv_wakeup_one(cv);
    300  1.16.4.2  yamt }
    301  1.16.4.2  yamt 
    302  1.16.4.2  yamt static void __noinline
    303  1.16.4.2  yamt cv_wakeup_one(kcondvar_t *cv)
    304  1.16.4.2  yamt {
    305       1.2    ad 	sleepq_t *sq;
    306  1.16.4.2  yamt 	kmutex_t *mp;
    307  1.16.4.2  yamt 	int swapin;
    308  1.16.4.2  yamt 	lwp_t *l;
    309       1.2    ad 
    310      1.15    ad 	KASSERT(cv_is_valid(cv));
    311      1.15    ad 
    312  1.16.4.2  yamt 	mp = sleepq_hashlock(cv);
    313  1.16.4.2  yamt 	sq = CV_SLEEPQ(cv);
    314  1.16.4.2  yamt 	l = TAILQ_FIRST(sq);
    315  1.16.4.2  yamt 	if (l == NULL) {
    316  1.16.4.2  yamt 		mutex_spin_exit(mp);
    317       1.2    ad 		return;
    318  1.16.4.2  yamt 	}
    319  1.16.4.2  yamt 	KASSERT(l->l_sleepq == sq);
    320  1.16.4.2  yamt 	KASSERT(l->l_mutex == mp);
    321  1.16.4.2  yamt 	KASSERT(l->l_wchan == cv);
    322  1.16.4.2  yamt 	swapin = sleepq_remove(sq, l);
    323  1.16.4.2  yamt 	mutex_spin_exit(mp);
    324       1.2    ad 
    325       1.2    ad 	/*
    326  1.16.4.2  yamt 	 * If there are newly awakend threads that need to be swapped in,
    327  1.16.4.2  yamt 	 * then kick the swapper into action.
    328       1.2    ad 	 */
    329  1.16.4.2  yamt 	if (swapin)
    330  1.16.4.2  yamt 		uvm_kick_scheduler();
    331      1.15    ad 
    332      1.15    ad 	KASSERT(cv_is_valid(cv));
    333       1.2    ad }
    334       1.2    ad 
    335       1.2    ad /*
    336       1.2    ad  * cv_broadcast:
    337       1.2    ad  *
    338       1.2    ad  *	Wake all LWPs waiting on a condition variable.  Must be called
    339       1.2    ad  *	with the interlocking mutex held.
    340       1.2    ad  */
    341       1.2    ad void
    342       1.2    ad cv_broadcast(kcondvar_t *cv)
    343       1.2    ad {
    344  1.16.4.2  yamt 
    345  1.16.4.2  yamt 	/* LOCKDEBUG_WAKEUP(CV_DEBUG_P(cv), cv, CV_RA); */
    346  1.16.4.2  yamt 	KASSERT(cv_is_valid(cv));
    347  1.16.4.2  yamt 
    348  1.16.4.2  yamt 	if (__predict_false(!TAILQ_EMPTY(CV_SLEEPQ(cv))))
    349  1.16.4.2  yamt 		cv_wakeup_all(cv);
    350  1.16.4.2  yamt }
    351  1.16.4.2  yamt 
    352  1.16.4.2  yamt static void __noinline
    353  1.16.4.2  yamt cv_wakeup_all(kcondvar_t *cv)
    354  1.16.4.2  yamt {
    355       1.2    ad 	sleepq_t *sq;
    356  1.16.4.2  yamt 	kmutex_t *mp;
    357  1.16.4.2  yamt 	int swapin;
    358  1.16.4.2  yamt 	lwp_t *l, *next;
    359       1.2    ad 
    360      1.15    ad 	KASSERT(cv_is_valid(cv));
    361      1.15    ad 
    362  1.16.4.2  yamt 	mp = sleepq_hashlock(cv);
    363  1.16.4.2  yamt 	swapin = 0;
    364  1.16.4.2  yamt 	sq = CV_SLEEPQ(cv);
    365  1.16.4.2  yamt 	for (l = TAILQ_FIRST(sq); l != NULL; l = next) {
    366  1.16.4.2  yamt 		KASSERT(l->l_sleepq == sq);
    367  1.16.4.2  yamt 		KASSERT(l->l_mutex == mp);
    368  1.16.4.2  yamt 		KASSERT(l->l_wchan == cv);
    369  1.16.4.2  yamt 		next = TAILQ_NEXT(l, l_sleepchain);
    370  1.16.4.2  yamt 		swapin |= sleepq_remove(sq, l);
    371  1.16.4.2  yamt 	}
    372  1.16.4.2  yamt 	mutex_spin_exit(mp);
    373       1.2    ad 
    374  1.16.4.2  yamt 	/*
    375  1.16.4.2  yamt 	 * If there are newly awakend threads that need to be swapped in,
    376  1.16.4.2  yamt 	 * then kick the swapper into action.
    377  1.16.4.2  yamt 	 */
    378  1.16.4.2  yamt 	if (swapin)
    379  1.16.4.2  yamt 		uvm_kick_scheduler();
    380      1.15    ad 
    381      1.15    ad 	KASSERT(cv_is_valid(cv));
    382       1.2    ad }
    383       1.2    ad 
    384       1.2    ad /*
    385      1.11    ad  * cv_wakeup:
    386      1.11    ad  *
    387      1.11    ad  *	Wake all LWPs waiting on a condition variable.  For cases
    388      1.11    ad  *	where the address may be waited on by mtsleep()/tsleep().
    389      1.11    ad  *	Not a documented call.
    390      1.11    ad  */
    391      1.11    ad void
    392      1.11    ad cv_wakeup(kcondvar_t *cv)
    393      1.11    ad {
    394      1.15    ad 
    395  1.16.4.2  yamt 	cv_wakeup_all(cv);
    396  1.16.4.2  yamt 	wakeup(cv);
    397      1.11    ad }
    398      1.11    ad 
    399      1.11    ad /*
    400       1.2    ad  * cv_has_waiters:
    401       1.2    ad  *
    402       1.2    ad  *	For diagnostic assertions: return non-zero if a condition
    403       1.2    ad  *	variable has waiters.
    404       1.2    ad  */
    405       1.7    ad bool
    406       1.2    ad cv_has_waiters(kcondvar_t *cv)
    407       1.2    ad {
    408       1.2    ad 
    409  1.16.4.2  yamt 	return !TAILQ_EMPTY(CV_SLEEPQ(cv));
    410       1.2    ad }
    411      1.15    ad 
    412      1.15    ad /*
    413      1.15    ad  * cv_is_valid:
    414      1.15    ad  *
    415      1.15    ad  *	For diagnostic assertions: return non-zero if a condition
    416      1.15    ad  *	variable appears to be valid.  No locks need be held.
    417      1.15    ad  */
    418      1.15    ad bool
    419      1.15    ad cv_is_valid(kcondvar_t *cv)
    420      1.15    ad {
    421      1.15    ad 
    422  1.16.4.2  yamt 	return CV_WMESG(cv) != deadcv && CV_WMESG(cv) != NULL;
    423      1.15    ad }
    424