Bao zhao wrote:
Hi,from http://www.uniforum.chi.il.us/slides/linuxkernel/LinuxKernel.ppt
Daniel P. Bovet said
"two cases of deferred allocation of resources in Linux (1) page frames (demand paging, Copy On Write) (2)floating point registers"
I cannot understand the second case.
Thanks for anyone's help.
It's because, during context switch, the floating point registers are not saved if the process hasn't used any floating point instruction, and, if previously saved, they are not restored until the process uses a floating point instruction.
IOW, when the kernel does a context switch it does not save FP registers, but disables the FPU, thus FP register accesses/insns will generate a fault. Threads, which use only integer registers can be scheduled at will -- they will not generate such faults. We have saved gratuitous save/restore of FPU registers.
If a thread attempts to use the FPU, it traps into the kernel. Now there are two cases:
- the FPU contains the registers of that thread, in which case the FPU is simply enabled. We have saved gratuitous save/restore of the FPU state
- the FPU contains the register of some other thread, in which case they are saved into that threads state and the current thread's registers are restored.
~velco
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/