/* * Disable or enable interrupts and adjust curspl setting. Return old * spl level. */ int splx(int spl) { struct thread *cur = curthread; int ret; if (cur->t_curspl < spl) { /* turning interrupts off */ splraise(cur->t_curspl, spl); ret = cur->t_curspl; cur->t_curspl = spl; } else if (cur->t_curspl > spl) { /* turning interrupts on */ ret = cur->t_curspl; cur->t_curspl = spl; spllower(ret, spl); } else { /* do nothing */ ret = spl; } return ret; }
/* * Release the lock. */ void spinlock_release(struct spinlock *lk) { /* this must work before curcpu initialization */ if (CURCPU_EXISTS()) { KASSERT(lk->lk_holder == curcpu->c_self); } lk->lk_holder = NULL; spinlock_data_set(&lk->lk_lock, 0); spllower(IPL_HIGH, IPL_NONE); }