Example #1
0
File: spl.c Project: Adam-Koza/A3
/*
 * 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;
}
Example #2
0
/*
 * 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);
}