return cv; }
if (cvar->nw > cvar->ns) { handshakes = cvar->nw - cvar->ns; cvar->ns = cvar->nw; release_sem_etc(cvar->sem, handshakes, B_DO_NOT_RESCHEDULE); if( atomic_add( &cvar->signalBenCount, -1 ) > 1 ) { release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE); }  while (acquire_sem_etc(cvar->handshakeSem, handshakes, 0, 0) == B_INTERRUPTED) { err = B_INTERRUPTED; } } else { if( atomic_add( &cvar->signalBenCount, -1 ) > 1 ) { release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE); } } return PR_SUCCESS; }
PR_IMPLEMENT(PRCondVar*)    PR_NewCondVar (PRLock *lock){    PRCondVar *cv = PR_NEW( PRCondVar );    PR_ASSERT( NULL != lock );    if( NULL != cv )    {	cv->lock = lock;	cv->sem = create_sem(0, "CVSem");	cv->handshakeSem = create_sem(0, "CVHandshake");	cv->signalSem = create_sem( 0, "CVSignal");	cv->signalBenCount = 0;	cv->ns = cv->nw = 0;	PR_ASSERT( cv->sem >= B_NO_ERROR );	PR_ASSERT( cv->handshakeSem >= B_NO_ERROR );	PR_ASSERT( cv->signalSem >= B_NO_ERROR );    }    return cv;} /* PR_NewCondVar */