sys/kern/kern_refcount.c
int
_refcount_release_wakeup_n(volatile u_int *countp, u_int i)
{
	u_int n;

	for (;;) {
		n = *countp;
		cpu_ccfence();
		if (n == (REFCNTF_WAITING | i)) {
			if (atomic_cmpset_int(countp, n, 0)) {
				wakeup(countp);
				n = i;
				break;
			}
		} else {
			KKASSERT(n != REFCNTF_WAITING); /* illegal state */
			if (atomic_cmpset_int(countp, n, n - i))
				break;
		}
	}
	return (n == i);
}
/*
 * This helper function implements the release-with-wakeup API.  It is
 * executed for the non-trivial case or if the atomic op races.
 *
 * On the i->0 transition is REFCNTF_WAITING is set it will be cleared
 * and a wakeup() will be issued.
 *
 * On any other transition we simply subtract (i) and leave the
 * REFCNTF_WAITING flag intact.
 *
 * This function returns TRUE(1) on the last release, whether a wakeup
 * occured or not, and FALSE(0) otherwise.
 *
 * NOTE!  (i) cannot be 0
 */
This helper function implements the release-with-wakeup API.  It is
executed for the non-trivial case or if the atomic op races.

On the i->0 transition is REFCNTF_WAITING is set it will be cleared
and a wakeup() will be issued.

On any other transition we simply subtract (i) and leave the
REFCNTF_WAITING flag intact.

This function returns TRUE(1) on the last release, whether a wakeup
occured or not, and FALSE(0) otherwise.

NOTE.  (i) cannot be 0
This helper function implements the release - with - wakeup API . It is executed for the non - trivial case or if the atomic op races . On the i - > 0 transition is REFCNTF_WAITING is set it will be cleared and a wakeup () will be issued . On any other transition we simply subtract ( i ) and leave the REFCNTF_WAITING flag intact . This function returns TRUE ( 1 ) on the last release whether a wakeup occured or not and FALSE ( 0 ) otherwise . NOTE . ( i ) cannot be 0
int
_refcount_release_wakeup_n(volatile u_int *countp, u_int i)
{
	u_int n;
	for (;;) {
		n = *countp;
		cpu_ccfence();
		if (n == (REFCNTF_WAITING | i)) {
			if (atomic_cmpset_int(countp, n, 0)) {
				wakeup(countp);
				n = i;
				break;
			}
		} else {
			KKASSERT(n != REFCNTF_WAITING); 
			if (atomic_cmpset_int(countp, n, n - i))
				break;
		}
	}
	return (n == i);
}
int _refcount_release_wakeup_n ( volatile u_int * countp , u_int i ) { u_int n ; for ( ; ; ) { n = * countp ; cpu_ccfence ( ) ; if ( n == ( REFCNTF_WAITING | i ) ) { if ( atomic_cmpset_int ( countp , n , 0 ) ) { wakeup ( countp ) ; n = i ; break ; } } else { KKASSERT ( n != REFCNTF_WAITING ) ; if ( atomic_cmpset_int ( countp , n , n - i ) ) break ; } } return ( n == i ) ; }
This helper function implements the release-with-wakeup API.
This helper function implements the release - with - wakeup API .
/* illegal state */