Page 1 of 1

Software context switching

Posted: Wed Aug 04, 2004 9:46 am
by slash
Can anyone tell how software context switching is performed without using TSS?
Is it really faster than harware switching?
I also need info on I/O protection and page fault handling.
Thanks

Re:Software context switching

Posted: Wed Aug 04, 2004 9:01 pm
by Dreamsmith
Can anyone tell how software context switching is performed without using TSS?
You manually store and restore the registers and stuff the TSS holds.
Is it really faster than harware switching?
Depends, but usually yes. The TSS holds a lot of information -- frequently more than you need. And your scheduler is normally invoked via some interrupt, so your ISR has already stored some of the stuff you need to store during a task switch. So to do a software task switch, you only need to store and restore what hasn't already been stored by the ISR entry routine. You can usually do this pretty quick. Your ISR would have to be pretty thin, and your save/restore requirements pretty great, for you to have to do so much work that it would take you longer than using a hardware task switch (which will store the entire state, including redundantly storing things you already stored).
I also need info on I/O protection and page fault handling.
Did you check the Intel docs (vol. 3)?