Subject: Re: Is there any way to tell if the current thread has a user context?
To: matthew green <mrg@eterna.com.au>
From: Alan Ritter <ritter.alan@gmail.com>
List: tech-kern
Date: 09/06/2005 10:02:01
--nextPart2760207.aAqIjVlcy9
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
On Tuesday 06 September 2005 5:34 am, matthew green wrote:
> > but from running the kernel debugger it seems that sometimes while
> > in my interrupt handler curlwp points to a "struct lwp" from a
> > thread that was previously running.
>
> I thought it was always supposed to be NULL in interrupt context,
> but looking at the code I don't see this set anywhere except the idle
> loop and on process exit. I guess it is just likely to be NULL at some
> point if you are in an interrupt and useful only for diagnostic tests.=20
> If this is correct, it looks like dev/ic/awi.c is using it incorrectly.
>
> curlwp/curproc can only safely be used in a process context. interrupt
> context code should never test/use them. their value in that context
> is not defined.
Thanks, this helps clarify a lot. As a temporary fix, I added a global=20
variable to indicate if I'm in a device interrupt or not, and test this=20
instead of curlwp. The only problem then is how to tell if I'm in a=20
software interrupt or callback/timeout function. It seems like curlwp is=20
NULL in these cases (I still have the curlwp!=3D NULL test in there, and it=
=20
seems to work), but I need to look into this more.
--nextPart2760207.aAqIjVlcy9
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (NetBSD)
iD8DBQBDHWkcdrBy3JhXjT8RAl4OAJ9BScVXitjzFgQ4PrdvX/bXbrhjYACfVbiP
gX/668j60Qis5QZ/kyHgZBg=
=jFND
-----END PGP SIGNATURE-----
--nextPart2760207.aAqIjVlcy9--