From: Jesper S. <js...@re...> - 2000-11-06 14:01:36
|
If I'm not mistaken, the SH implementation of lazy FPU switching isn't really lazy. It always saves the FPU state on a context switch: /* * switch_to(x,y) should switch tasks from x to y. * */ void __switch_to(struct task_struct *prev, struct task_struct *next) { #if defined(__SH4__) if (prev != &init_task) { unsigned long flags; save_and_cli(flags); unlazy_fpu(prev); restore_flags(flags); } #endif /* * Restore the kernel mode register * k7 (r7_bank1) */ asm volatile("ldc %0, r7_bank" : /* no output */ :"r" (next)); } For it to work properly (lazy fashion) it should just clear the FD flag at that point, and have some magic in do_fpu_state_restore() to save the registers to the previous FPU using task before loading the FPU again. If that previous task is current, no saving/restoring is necessary. I think the current implementation is probably due to being based on the i386 where (apparently) there's no gain in lazy switching. I don't know if lazy switching is suitable for embedded targets (the goal being performance). Probably would make sense to clear out the FPU when not used, allowing the FPU circuitry to be powered down [if that's possible in the SH4 CPUs]. Just my $.02 having happened to read the code. I don't have a SH4 board myself. Cheers, Jesper |