659 mblist->mbl_tail_indx = mbox_indx;
660 mblist->mbl_head_indx = mbox_indx;
661 }
662
663 /*
664 * Because we can have both waiters (SLEEP treads waiting for a
665 * cv_signal to continue processing) and pollers (NOSLEEP treads
666 * polling for a mailbox to become available), we try to share CPU time
667 * between them. We do this by signalling the waiters only every other
668 * call to mbox_free. This gives the pollers a chance to get some CPU
669 * time to do their command. If we signalled every time, the pollers
670 * would have a much harder time getting CPU time.
671 *
672 * If there are waiters and no pollers, then we signal always.
673 *
674 * Otherwise, if there are either no waiters, there may in fact be
675 * pollers, so we do not signal in that case.
676 */
677 if (mblist->mbl_pollers > 0 && mblist->mbl_waiters > 0) {
678 /* flip the signal value */
679 mblist->mbl_signal = (++mblist->mbl_signal) % 2;
680 } else if (mblist->mbl_waiters > 0) {
681 mblist->mbl_signal = 1;
682 } else {
683 mblist->mbl_signal = 0;
684 }
685
686 /*
687 * Depending on the conditions in the previous check, we signal only if
688 * we are supposed to.
689 */
690 if (mblist->mbl_signal) {
691 mblist->mbl_waiters--;
692 cv_signal(&mblist->mbl_cv);
693 }
694
695 /* Clear out the mailbox entry pointer */
696 *mb = NULL;
697
698 mutex_exit(&mblist->mbl_lock);
699
|
659 mblist->mbl_tail_indx = mbox_indx;
660 mblist->mbl_head_indx = mbox_indx;
661 }
662
663 /*
664 * Because we can have both waiters (SLEEP treads waiting for a
665 * cv_signal to continue processing) and pollers (NOSLEEP treads
666 * polling for a mailbox to become available), we try to share CPU time
667 * between them. We do this by signalling the waiters only every other
668 * call to mbox_free. This gives the pollers a chance to get some CPU
669 * time to do their command. If we signalled every time, the pollers
670 * would have a much harder time getting CPU time.
671 *
672 * If there are waiters and no pollers, then we signal always.
673 *
674 * Otherwise, if there are either no waiters, there may in fact be
675 * pollers, so we do not signal in that case.
676 */
677 if (mblist->mbl_pollers > 0 && mblist->mbl_waiters > 0) {
678 /* flip the signal value */
679 mblist->mbl_signal = (mblist->mbl_signal + 1) % 2;
680 } else if (mblist->mbl_waiters > 0) {
681 mblist->mbl_signal = 1;
682 } else {
683 mblist->mbl_signal = 0;
684 }
685
686 /*
687 * Depending on the conditions in the previous check, we signal only if
688 * we are supposed to.
689 */
690 if (mblist->mbl_signal) {
691 mblist->mbl_waiters--;
692 cv_signal(&mblist->mbl_cv);
693 }
694
695 /* Clear out the mailbox entry pointer */
696 *mb = NULL;
697
698 mutex_exit(&mblist->mbl_lock);
699
|