To: Joe NYC who wrote (74163 ) 3/11/2002 6:25:38 AM From: Gopher Broke Respond to of 275872 Let's be clear. Calling conventions are irrelevant to the discussion of saving/restoring a thread's registers and state information. All that is required for a simple function call is that the caller and callee agree on the the conventions they use, which could range from saving everything to saving nothing. We have conventions like "C" and "Pascal" so that code generated by one compiler can be invoked by code generated by another compiler. No other reason. Similarly, device drivers do not have to save and restore all registers on entry/exit, although many do just for convenience. They only need to restore the exact state when the interrupt occurred, which is only that set of registers they modify. (This is still more onerous than a regular function call, however, because calling conventions generally allow subroutines to use some work registers without having to restore them.) The most interesting area of register save/restore is the area of preemptive thread switching. In this case, when each interrupt handler completes, the scheduler is invoked to determine if a new thread should be executed. If so, the scheduler must save and restore the entire thread context. All registers and flags must be saved/restored. In x86-32 the processor provides assistance in the form of a task state segment (TSS). Calling through a TSS will automatically store the current state in the running TSS and restore the state of the target TSS. And finally, to return to the topic, in x86-64 it seems that task switching through the TSS is not supported in long mode. The scheduler must therefore manually save/restore the registers to/from the blocked thread's stack. I guess AMD determined that there was little benefit in having hardware assist (or perhaps that no OSs bother to use the TSS mechanism)?