Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Dec 2008 21:42:45 -0800
From:      Xin LI <delphij@delphij.net>
To:        Ravi Murty <ravi.murty@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: td_critnest
Message-ID:  <4945EE55.2050401@delphij.net>
In-Reply-To: <95b10a340812142103u3ab8bd2br97033a7c7e8bec3@mail.gmail.com>
References:  <95b10a340812142103u3ab8bd2br97033a7c7e8bec3@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ravi Murty wrote:
> Hello All,
> 
> The implementation of critical_enter and critical_exit changed between
> freebsd 5 and freebsd 6. In the newer implemtnation, the code checks if
> td_critnest is 1 and if it is sets it to zero, then checks if the thread
> owes a preempt. If so, it increments td_critnest by 1 before grabbing a lock
> and then decrements it back to zero. I can't figure out why it does this.
> The freebsd 5 implementation seems straightforward where we check if the
> thread owes a preempt and if so we switch to the new thread. Can anyone help
> me with this?

My guess is to prevent race conditions (i.e. to split the owepreempt
flag into a separate variable), since this value could be changed in an
interrupt context, and not only during the current thread context.

Cheers,
- --
Xin LI <delphij@delphij.net>	http://www.delphij.net/
FreeBSD - The Power to Serve!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAklF7lUACgkQi+vbBBjt66C0sQCeOZCFZu4VBTRk3it4/424pAbc
LRoAoLfdoS09ZX2SSZ1Z/SOw+rqkrkQ0
=P2Ez
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4945EE55.2050401>