Page 1 of 1

Disabling Ints in Switching

Posted: Mon Jan 16, 2006 2:36 pm
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 ?

Re:Disabling Ints in Switching

Posted: Tue Jan 17, 2006 6:53 am
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.