Subject: Re: CVS commit: src/sys/kern
To: Joerg Sonnenberger <joerg@NetBSD.org>
From: Andrew Doran <ad@netbsd.org>
List: source-changes
Date: 10/16/2007 12:28:00
On Tue, Oct 16, 2007 at 11:14:50AM +0000, Joerg Sonnenberger wrote:

> On Fri, Oct 12, 2007 at 01:00:18PM +0000, Andrew Doran wrote:
> > - Add crit_enter()/crit_exit(). These bound critical sections in which
> >   kernel preemption is to be disabled. Better names welcome.
> 
> How cheap are those

Something like:

crit_enter()
{
	curlwp->l_nopreempt++;
}

crit_exit()
{
	if (--curlwp->l_nopreempt == 0 && curlwp->l_dopreempt)
		preempt();
}

> and are they intended to replace short-term splhigh/splx use?

No, only to prevent real-time threads from preempting something else in the
kernel. Raising the spl should also do the same since the preemption must
happen on return from interrupt, but that's overkill.

The Linux (preempt_disable) or Solaris (kpreempt_disable) names look more
reasonable.

Andrew