Subject: Re: yamt-idlelwp: setting curlwp in MI code.
To: None <tech-kern@netbsd.org>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 04/05/2007 23:39:29
YAMAMOTO Takashi wrote:

> how about having set_curlwp() which can be overridden by MD definition?

Did you envision a new place where it would be used?

On Thu, Apr 05, 2007 at 03:13:37PM -0700, Matt Thomas wrote:

> While I think the goal of setting curlwp in MI code is laudable, it's 
> incomplete.  For PowerPC, I also need to set "curpcb" and "curpm" (which
> I currently do in cpu_switchto).

Without looking at the ppc code, elsewhere curpcb is obsolete since the
seperate idle PCB disappears.

> I think we should have a
> #deifne cpu_set_curlwp(ci, l) macro which if undefined is simply
> 
> #ifndef cpu_set_curlwp
> #define cpu_set_curlwp(ci, l) ((void)((ci)->ci_curlwp = (l)))
> #endif
> 
> Then on ppc, I could do
> #define cpu_set_curlwp(ci, l) do { \
>   (ci)->ci_curlw = (l); \
>   (ci)->ci_curpcb = &l->l_addr->u_pcb; \
>   (ci)->ci_curpm = (ci)->ci_curpcb->pcb_pm; \
> } while (0)
> 
> I'm sure that other ports which have similar needs...
> Anyone else need this?

I think there should be only two places curlwp needs to be set: before
main() is called and when switching to another LWP. Personally, I think
it's nicer to set them in the MD code.

Cheers,
Andrew