Disabling Ints in 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
Unlink

Disabling Ints in Switching

Post by Unlink »

Hi :)
Why must i disable interrupts when i'm switching tasks ?
Since i defined a global pointer for current task which i always use to switch context in all interrupts, if i want to switch process i just change that pointer, if i don't i just keep it like this BUT i always switch tasks in all interrupts.
So, if the pointer is unchanged the task switches to itself.

I think this is wasting of cpu time , is there is a better approch ?

Since i do context switching in all interrupts so disable interrupts in the begging of each ISR the enable it before IRET.
So does that prevent nested interrupts or any other feature ?
However, in my tests i found that disabling & re-enabling interrupts during context switching doesn't make sense, does any one agree with me ?
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:Disabling Ints in Switching

Post by kataklinger »

When CPU recive interrupt it masks interrupt flag as part of transfering control to ISR. When CPU execute IRET it pops EFLAG from stack, and it'll enable interrupt if they were enabled before interrupt. So you don't need to add CLI and STI instruction on top and bottom of ISR. But maybe you want to enable interrupts after CPU enter bottom half handler which can be interrupted.
Post Reply