kth: Remove irq_okay from sems and CVs It wasn't necessary. The only use for it was one assertion. If that assert would have failed, then the spinlock code will also fail (assuming SPINLOCK_DEBUG is on). Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/kern/include/kthread.h b/kern/include/kthread.h index d9c8a74..3a4bdb5 100644 --- a/kern/include/kthread.h +++ b/kern/include/kthread.h
@@ -73,7 +73,6 @@ struct kthread_tailq waiters; int nr_signals; spinlock_t lock; - bool irq_okay; }; #ifdef CONFIG_SEMAPHORE_DEBUG @@ -87,7 +86,6 @@ .waiters = TAILQ_HEAD_INITIALIZER((name).waiters), \ .nr_signals = (n), \ .lock = SPINLOCK_INITIALIZER, \ - .irq_okay = FALSE, \ KTH_DB_INIT \ } @@ -96,7 +94,6 @@ .waiters = TAILQ_HEAD_INITIALIZER((name).waiters), \ .nr_signals = (n), \ .lock = SPINLOCK_INITIALIZER_IRQSAVE, \ - .irq_okay = TRUE, \ KTH_DB_INIT \ } @@ -108,7 +105,6 @@ spinlock_t *lock; /* usually points to internal_ */ spinlock_t internal_lock; unsigned long nr_waiters; - bool irq_okay; }; struct cv_lookup_elm {
diff --git a/kern/src/kthread.c b/kern/src/kthread.c index dbe6ae7..f407f1d 100644 --- a/kern/src/kthread.c +++ b/kern/src/kthread.c
@@ -307,14 +307,12 @@ { sem_init_common(sem, signals); spinlock_init(&sem->lock); - sem->irq_okay = FALSE; } void sem_init_irqsave(struct semaphore *sem, int signals) { sem_init_common(sem, signals); spinlock_init_irqsave(&sem->lock); - sem->irq_okay = TRUE; } bool sem_trydown_bulk(struct semaphore *sem, int nr_signals) @@ -721,7 +719,6 @@ cv->lock = &cv->internal_lock; spinlock_init(cv->lock); - cv->irq_okay = FALSE; } void cv_init_irqsave(struct cond_var *cv) @@ -730,7 +727,6 @@ cv->lock = &cv->internal_lock; spinlock_init_irqsave(cv->lock); - cv->irq_okay = TRUE; } void cv_init_with_lock(struct cond_var *cv, spinlock_t *lock) @@ -738,15 +734,11 @@ __cv_raw_init(cv); cv->lock = lock; - cv->irq_okay = FALSE; } void cv_init_irqsave_with_lock(struct cond_var *cv, spinlock_t *lock) { - __cv_raw_init(cv); - - cv->lock = lock; - cv->irq_okay = TRUE; + cv_init_with_lock(cv, lock); } void cv_lock(struct cond_var *cv) @@ -779,8 +771,9 @@ smp_idle(); } -/* Comes in locked. The initial cv_lock would have disabled irqs (if - * applicable). */ +/* Comes in locked. Regarding IRQs, the initial cv_lock_irqsave would have + * disabled irqs. When this returns, IRQs would still be disabled. If it was a + * regular cv_lock(), IRQs will be enabled when we return. */ void cv_wait_and_unlock(struct cond_var *cv) { bool irqs_were_on = irq_is_enabled(); @@ -806,12 +799,11 @@ } /* Comes in locked. Note cv_lock does not disable irqs. They should still be - * disabled from the initial cv_lock_irqsave(). */ + * disabled from the initial cv_lock_irqsave(), which cv_wait_and_unlock() + * maintained. */ void cv_wait(struct cond_var *cv) { cv_wait_and_unlock(cv); - if (cv->irq_okay) - assert(!irq_is_enabled()); cv_lock(cv); }