I am doing software context switching. I have 1 main process for the kernel which is only given control when there are no processes left in the process queue. So the kernel’s process is only executed when the CPU is idle. Now the good news is that all processes work simultaneously as long as there is only IRQ0 fired. After for example 40 to 50 IRQ12 (for mouse), I will get a general protection fault with this message:
Code: Select all
00033103936e[CPU0 ] branch_far: EIP > limit
What I am doing is that I am saving the state of the current task when any of the IRQs is fired. In all of the IRQs, I first disable all other IRQs and then re enable them right before the task switch.
I really don’t know if what I think is correct or not but I’d really appreciate it if somebody could confirm the accuracy of this:
When IRQ0 is fired from CPL/DPL 0 to CPL/DPL 0 again, the stack’s contents will look like this (From top to bottom):
When IRQ0 is fired from CPL/DPL 3 to CPL/DPL 0, the processor will fetch SS0:ESP0 from the TSS and then sets them as the current SS:ESP. The processor will then push these values into the new stack:
Code: Select all
SS (of the process)
ESP (of the process)
EFLAGS (of the process)
CS (of the process)
EIP (of the process)
…
Therefore when IRQ0 is fired, I should save this information in the current process’s structure. Now if anyone can give me a hint on what I might be doing wrong, I’d really appreciate it. If you need the source code to be able to find the error’s source, I can put the source code here. Just tell me what should be put here so that someone can find the problem because I have been struggling with it for days and I can’t find it out and it is really frustrating. Thanks in advance.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.