Context switch on timer interrupt

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.
xmm15
Member
Member
Posts: 27
Joined: Mon Dec 16, 2013 6:50 pm

Re: Context switch on timer interrupt

Post by xmm15 »

bzt wrote:First, you need to save and restore ALL registers for a context switch. This also includes xmm,sse etc. registers if you use float or double in your C++ code.
I would just like to point out that you should probably not save xmm registers on every context switch, but rather leverage the use of #NM exception. For more info look at http://www.dumais.io/index.php?article= ... e8f88ee169
LtG
Member
Member
Posts: 384
Joined: Thu Aug 13, 2015 4:57 pm

Re: Context switch on timer interrupt

Post by LtG »

xmm15 wrote:
bzt wrote:First, you need to save and restore ALL registers for a context switch. This also includes xmm,sse etc. registers if you use float or double in your C++ code.
I would just like to point out that you should probably not save xmm registers on every context switch, but rather leverage the use of #NM exception. For more info look at http://www.dumais.io/index.php?article= ... e8f88ee169
Not saving them on every context switch is just on optimization, so doesn't really matter that much. Of course later you'll want to take advantage of that optimization, but if you keep it in mind it shouldn't be difficult to implement later as well.

Once you realize why you don't have to save these regs on every context switch you hopefully realize that it (partially) applies to all the regs, including general purpose and segment regs as well.
Post Reply