Nigel Spon nigel at adi.co.nz
Tue May 7 04:34:03 UTC 2002


I seem to have encountered an undocumented feature of the 
_CPU_Context_Switch routine on the PowerPC (and perhaps generally on 
other CPUs). My implementation was unordered - that is, I read and wrote 
from the context structures in bursts. This seems to be Bad Thing To Do, 
because my system was occasionally falling over under interrupt load with 
impossible values in the registers, looking very much like a context 
switch gone wrong. When I changed to writing out all the old context 
before I read in the new values, the problem disappeared. I find, to my 
surprise, that interrupts are on during this rather delicate operation, 
but I can't quite figure out why changing the order of things had such a 
devastating effect. 

Does anyone have any ideas as to what happened? Perhaps there should be a 
comment about the importance of saving all the old context before 
installing any of the new in that piece of code...


More information about the users mailing list