--- /home/rookie/perforce/smpng/attilio_smpng/i386/i386/intr_machdep.c Thu Jun 7 23:33:08 2007 +++ intr_machdep.c Mon Sep 24 23:49:41 2007 @@ -61,6 +61,8 @@ typedef void (*mask_fn)(void *); +extern struct mtx intr_wait_lock; + static int intrcnt_index; static struct intsrc *interrupt_sources[NUM_IO_INTS]; static struct sx intr_table_lock; @@ -481,6 +483,7 @@ STAILQ_INIT(&pics); sx_init(&intr_table_lock, "intr sources"); mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN); + mtx_init(&intr_wait_lock, "intr wait state", NULL, MTX_SPIN); } SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL) --- /home/rookie/perforce/smpng/attilio_smpng/kern/kern_intr.c Thu Jun 7 23:33:11 2007 +++ kern_intr.c Mon Sep 24 23:48:02 2007 @@ -76,6 +76,7 @@ uintptr_t event; }; +struct mtx intr_wait_lock; struct intr_event *clk_intr_event; struct intr_event *tty_intr_event; void *softclock_ih; @@ -342,7 +343,9 @@ if (error) panic("kthread_create() failed with %d", error); td = FIRST_THREAD_IN_PROC(p); /* XXXKSE */ + mtx_lock_spin(&intr_wait_lock); thread_lock(td); + thread_lock_set(td, &intr_wait_lock); sched_class(td, PRI_ITHD); TD_SET_IWAIT(td); thread_unlock(td); @@ -367,7 +370,9 @@ if (error) panic("kthread_create() failed with %d", error); td = FIRST_THREAD_IN_PROC(p); /* XXXKSE */ + mtx_lock_spin(&intr_wait_lock); thread_lock(td); + thread_lock_set(td, &intr_wait_lock); sched_class(td, PRI_ITHD); TD_SET_IWAIT(td); thread_unlock(td); @@ -1128,12 +1133,15 @@ * lock. This may take a while and it_need may get * set again, so we have to check it again. */ + mtx_lock_spin(&intr_wait_lock); thread_lock(td); if (!ithd->it_need && !(ithd->it_flags & IT_DEAD)) { + thread_lock_set(td, &intr_wait_lock); TD_SET_IWAIT(td); ie->ie_count = 0; mi_switch(SW_VOL, NULL); - } + } else + mtx_unlock_spin(&intr_wait_lock); thread_unlock(td); } } @@ -1202,12 +1210,15 @@ * lock. This may take a while and it_need may get * set again, so we have to check it again. */ + mtx_lock_spin(&intr_wait_lock); thread_lock(td); if (!ithd->it_need && !(ithd->it_flags & IT_DEAD)) { + thread_lock_set(td, &intr_wait_lock); TD_SET_IWAIT(td); ie->ie_count = 0; mi_switch(SW_VOL, NULL); - } + } else + mtx_unlock_spin(&intr_wait_lock); thread_unlock(td); } }