Software context switching

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
slash

Software context switching

Post 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
Dreamsmith

Re:Software context switching

Post 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)?
Post Reply