Page 1 of 1

Interrupts and stack

Posted: Fri Dec 19, 2003 3:17 pm
by proxy
ok, just out of curiosity, how do i specify where the stack pointer should start on an interrupt? does that require a TSS? cause right now i'm using setjmp method.

currently it seem to be sharing same area for stack as normal thread uses, which is obviously very bad...

proxy

Re:Interrupts and stack

Posted: Fri Dec 19, 2003 5:20 pm
by df
the only way to give a different stack to an interrupt is to set each up with its own tss or callgate etc.

otherwise, they do share the stack

Re:Interrupts and stack

Posted: Fri Dec 19, 2003 5:54 pm
by Tim
Then again, if you handle your interrupts in ring 0, and you have some code running in ring 3, you will need a TSS. If the processor handles a ring 0 interrupt while it's running in ring 3, it automatically load SS and ESP from the ring 0 pointers in the current TSS and uses those. If you don't have a TSS, and the CPU needs to handle a ring 0 interrupt in ring 3, you get a triple fault.

Conclusion: the CPU does automatic stack switching on interrupts, but you need to provide a couple of TSS fields for it to work -- even if you're not using TSS task switching.

Re:Interrupts and stack

Posted: Sun Dec 21, 2003 1:39 am
by AceMan
I just want to know about IDTR. I load IDT using fixed address 0x800 before enable paging I map first 4MB onto itself in paging if i unmap first 4MB can i be able to use the IDT or must i have to map IDT somewhere before unmapping. Please help. Thank you.

Re:Interrupts and stack

Posted: Sun Dec 21, 2003 8:27 am
by Slasher
No, if you unmap the memory area where the IDT and GDT are mapped then the system will crash.
The Gdt and Idt use Linear addresses and so need the mapping. It is only the page directory and page tables that use physical addresses directly.(reason being you can not do paging if the page directory and tables are paged/mapped ie use linear addresses cause there will be nothing to resolve their addresses)