836 (void *)pool_p));
837
838 /* Lock the pool */
839 mutex_enter(&pool_p->ipool_lock);
840
841 /* Perform initial balance if required */
842 if (pool_p->ipool_reqno > pool_p->ipool_resno)
843 i_ddi_irm_balance(pool_p);
844
845 /* Activate the pool */
846 pool_p->ipool_flags |= DDI_IRM_FLAG_ACTIVE;
847
848 /*
849 * Main loop.
850 * Iterate once first before wait on signal, in case there is signal
851 * sent before this thread being created
852 */
853 for (;;) {
854
855 /* Compute the delay interval */
856 interval = drv_usectohz(irm_balance_delay * 1000000);
857
858 /* Wait one interval, or until there are waiters */
859 if ((interval > 0) &&
860 !(pool_p->ipool_flags & DDI_IRM_FLAG_WAITERS) &&
861 !(pool_p->ipool_flags & DDI_IRM_FLAG_EXIT)) {
862 (void) cv_reltimedwait(&pool_p->ipool_cv,
863 &pool_p->ipool_lock, interval, TR_CLOCK_TICK);
864 }
865
866 /* Check if awakened to exit */
867 if (pool_p->ipool_flags & DDI_IRM_FLAG_EXIT) {
868 DDI_INTR_IRMDBG((CE_CONT,
869 "irm_balance_thread: exiting...\n"));
870 mutex_exit(&pool_p->ipool_lock);
871 thread_exit();
872 }
873
874 /* Balance the pool */
875 i_ddi_irm_balance(pool_p);
876
|
836 (void *)pool_p));
837
838 /* Lock the pool */
839 mutex_enter(&pool_p->ipool_lock);
840
841 /* Perform initial balance if required */
842 if (pool_p->ipool_reqno > pool_p->ipool_resno)
843 i_ddi_irm_balance(pool_p);
844
845 /* Activate the pool */
846 pool_p->ipool_flags |= DDI_IRM_FLAG_ACTIVE;
847
848 /*
849 * Main loop.
850 * Iterate once first before wait on signal, in case there is signal
851 * sent before this thread being created
852 */
853 for (;;) {
854
855 /* Compute the delay interval */
856 interval = drv_sectohz(irm_balance_delay);
857
858 /* Wait one interval, or until there are waiters */
859 if ((interval > 0) &&
860 !(pool_p->ipool_flags & DDI_IRM_FLAG_WAITERS) &&
861 !(pool_p->ipool_flags & DDI_IRM_FLAG_EXIT)) {
862 (void) cv_reltimedwait(&pool_p->ipool_cv,
863 &pool_p->ipool_lock, interval, TR_CLOCK_TICK);
864 }
865
866 /* Check if awakened to exit */
867 if (pool_p->ipool_flags & DDI_IRM_FLAG_EXIT) {
868 DDI_INTR_IRMDBG((CE_CONT,
869 "irm_balance_thread: exiting...\n"));
870 mutex_exit(&pool_p->ipool_lock);
871 thread_exit();
872 }
873
874 /* Balance the pool */
875 i_ddi_irm_balance(pool_p);
876
|