td->td_critnest manipulations do not use atomic_add_int ?

John Baldwin jhb at freebsd.org
Wed Dec 21 08:19:40 PST 2005


On Tuesday 20 December 2005 10:04 pm, Joseph Koshy wrote:
> lr> is td ever != curthread?
>
> jhb> No.
>
> I don't think we KASSERT() this in enough places in the code
> though.

void
critical_enter(void)
{
	struct thread *td;

	td = curthread;
	td->td_critnest++;
	CTR4(KTR_CRITICAL, "critical_enter by thread %p (%ld, %s) to %d", td,
	    (long)td->td_proc->p_pid, td->td_proc->p_comm, td->td_critnest);
}

void
critical_exit(void)
{
	struct thread *td;

	td = curthread;
	KASSERT(td->td_critnest != 0,
	..
}

Need I say more?  Clearly td == curthread.

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-current mailing list