Subject: Re: more funky stuff with kthreads and interrupts
To: Toru Nishimura <nisimura@itc.aist-nara.ac.jp>
From: Michael L. Hitch <mhitch@lightning.msu.montana.edu>
List: port-mips
Date: 05/01/2001 23:56:28
On Wed, 2 May 2001, Toru Nishimura wrote:

> >  I now see what is happening.  On the pmax, the initial SR value is
> > initialized in the pcb before calling main().  However, the kernel has
> > called tsleep() at least once prior to forking any kthread processes,
> > and tsleep() results in cpu_switch() being called at a non-zero SPL.
> > Cpu_switch() saves the current SR in the current pcb - oops.
> 
> The problem seems derived from a mismatch between pcb0 contents and
> processor state at the time configure() completes inside main().

  The saved SR in the pcb will be updated anytime the kernel calls
cpu_switch(), which could occur well after configure() is done - a prime
example could be when mounting the root filesystem.

> So, I propose here to make sure processor state (spl0) gets in sync
> with pcb0 at the bottom of cpu_configure().  This could be done, [1]
> special "trumpoline" code to make self-context switch of proc0 (==
> kernel itself), or [2] uglier but just straight piece of codes.

  I'm quite certain that mounting the root file system, which is done
after cpu_configure() will save a non-spl0() SR value in the pcb, so doing
anything in cpu_configure() would be lost anywayt.

--
Michael L. Hitch			mhitch@montana.edu
Computer Consultant
Information Technology Center
Montana State University	Bozeman, MT	USA