680 mblist->mbl_tail_indx = mbox_indx;
681 mblist->mbl_head_indx = mbox_indx;
682 }
683
684 /*
685 * Because we can have both waiters (SLEEP treads waiting for a
686 * cv_signal to continue processing) and pollers (NOSLEEP treads
687 * polling for a mailbox to become available), we try to share CPU time
688 * between them. We do this by signalling the waiters only every other
689 * call to mbox_free. This gives the pollers a chance to get some CPU
690 * time to do their command. If we signalled every time, the pollers
691 * would have a much harder time getting CPU time.
692 *
693 * If there are waiters and no pollers, then we signal always.
694 *
695 * Otherwise, if there are either no waiters, there may in fact be
696 * pollers, so we do not signal in that case.
697 */
698 if (mblist->mbl_pollers > 0 && mblist->mbl_waiters > 0) {
699 /* flip the signal value */
700 mblist->mbl_signal = (++mblist->mbl_signal) % 2;
701 } else if (mblist->mbl_waiters > 0) {
702 mblist->mbl_signal = 1;
703 } else {
704 mblist->mbl_signal = 0;
705 }
706
707 /*
708 * Depending on the conditions in the previous check, we signal only if
709 * we are supposed to.
710 */
711 if (mblist->mbl_signal) {
712 mblist->mbl_waiters--;
713 cv_signal(&mblist->mbl_cv);
714 }
715
716 /* Clear out the mailbox entry pointer */
717 *mb = NULL;
718
719 mutex_exit(&mblist->mbl_lock);
720 }
|
680 mblist->mbl_tail_indx = mbox_indx;
681 mblist->mbl_head_indx = mbox_indx;
682 }
683
684 /*
685 * Because we can have both waiters (SLEEP treads waiting for a
686 * cv_signal to continue processing) and pollers (NOSLEEP treads
687 * polling for a mailbox to become available), we try to share CPU time
688 * between them. We do this by signalling the waiters only every other
689 * call to mbox_free. This gives the pollers a chance to get some CPU
690 * time to do their command. If we signalled every time, the pollers
691 * would have a much harder time getting CPU time.
692 *
693 * If there are waiters and no pollers, then we signal always.
694 *
695 * Otherwise, if there are either no waiters, there may in fact be
696 * pollers, so we do not signal in that case.
697 */
698 if (mblist->mbl_pollers > 0 && mblist->mbl_waiters > 0) {
699 /* flip the signal value */
700 mblist->mbl_signal = (mblist->mbl_signal + 1) % 2;
701 } else if (mblist->mbl_waiters > 0) {
702 mblist->mbl_signal = 1;
703 } else {
704 mblist->mbl_signal = 0;
705 }
706
707 /*
708 * Depending on the conditions in the previous check, we signal only if
709 * we are supposed to.
710 */
711 if (mblist->mbl_signal) {
712 mblist->mbl_waiters--;
713 cv_signal(&mblist->mbl_cv);
714 }
715
716 /* Clear out the mailbox entry pointer */
717 *mb = NULL;
718
719 mutex_exit(&mblist->mbl_lock);
720 }
|