Software Vs Hardware Context Switching
Context switching can be performed primarily by software or hardware. Some processors, like the Intel 80386 and its successors, have hardware support for context switches, by making use of a special data segment designated the Task State Segment or TSS. A task switch can be explicitly triggered with a CALL or JMP instruction targeted at a TSS descriptor in the global descriptor table. It can occur implicitly when an interrupt or exception is triggered if there's a task gate in the interrupt descriptor table. When a task switch occurs the CPU can automatically load the new state from the TSS. As with other tasks performed in hardware, one would expect this to be rather fast; however, mainstream operating systems, including Windows and Linux, do not use this feature.
This is due to mainly two reasons:
- hardware context switching does not save all the registers (only general purpose registers, not floating point registers — although the TS bit is automatically turned on in the CR0 control register, resulting in a fault when executing floating point instructions and giving the OS the opportunity to save and restore the floating point state as needed).
- associated performance issues, e.g., software context switching can be selective and store only those registers that need storing, whereas hardware context switching stores nearly all registers whether they're required or not.
Read more about this topic: Context Switch
Famous quotes containing the words hardware and/or context:
“A friend of mine spoke of books that are dedicated like this: To my wife, by whose helpful criticism ... and so on. He said the dedication should really read: To my wife. If it had not been for her continual criticism and persistent nagging doubt as to my ability, this book would have appeared in Harpers instead of The Hardware Age.”
—Brenda Ueland (18911985)
“The hippie is the scion of surplus value. The dropout can only claim sanctity in a society which offers something to be dropped out ofcareer, ambition, conspicuous consumption. The effects of hippie sanctimony can only be felt in the context of others who plunder his lifestyle for what they find good or profitable, a process known as rip-off by the hippie, who will not see how savagely he has pillaged intricate and demanding civilizations for his own parodic lifestyle.”
—Germaine Greer (b. 1939)