Vol. 3 6-45
INTERRUPT AND EXCEPTION HANDLING
If an invalid TSS exception occurs during a task switch, it can occur before or after
the commit-to-new-task point. If it occurs before the commit point, no program state
change occurs. If it occurs after the commit point (when the segment descriptor
information for the new segment selectors have been loaded in the segment regis-
ters), the processor will load all the state information from the new TSS before it
generates the exception. During a task switch, the processor first loads all the
segment registers with segment selectors from the TSS, then checks their contents
for validity. If an invalid TSS exception is discovered, the remaining segment regis-
ters are loaded but not checked for validity and therefore may not be usable for refer-
encing memory. The invalid TSS handler should not rely on being able to use the
segment selectors found in the CS, SS, DS, ES, FS, and GS registers without causing
another exception. The exception handler should load all segment registers before
trying to resume the new task; otherwise, general-protection exceptions (#GP) may
result later under conditions that make diagnosis more difficult. The Intel recom-
mended way of dealing situation is to use a task for the invalid TSS exception
handler. The task switch back to the interrupted task from the invalid-TSS ex ception-
handler task will then cause the processor to check the registers as it loads them
from the TSS.