Code:
sched_time_handler:
Interrupt handlers should not start with CLI. If you need interrupts disabled, use an interrupt gate. If you're not using an interrupt gate, interrupts may arrive before the CLI and overflow your stack.
You push EBP but there's no corresponding pop, so the IRET does not pop the correct return address.
You call a C function without saving the registers that may be clobbered by a C function and without clearing the direction flag.
STI before IRET does nothing. IRET pops EFLAGS from the stack, and the stored EFLAGS value determines whether interrupts will be enabled.
Code:
kernel_pf_handler:
Exception handlers should not start with CLI. If you need interrupts disabled, use an interrupt gate. If you're not using an interrupt gate, interrupts may arrive before the CLI and overflow your stack.
You pop the error code into EBX, overwriting the interrupted program's state.
You push EBX without a corresponding pop, causing POPAD and IRET to pop the wrong values from the stack.
You call a C function without clearing the direction flag.
STI before IRET does nothing.
KrotovOSdev wrote:
I think the problem is stack overflow.
Your code has several problems. It's hard to say which one is causing the crash without debugging.
KrotovOSdev wrote:
When interrupt handler is called it calls resched() which leads to creating a stack frame.
Rescheduling should not involve creating anything, just switching from one task to another. (And you probably should not switch tasks on every timer interrupt!)
KrotovOSdev wrote:
If I'm right (but i maybe not) I have somehow to bypass it. How can I do this?
If you don't want to switch tasks on every timer interrupt, keep track of how many timer interrupts have arrived since the last time you've switched tasks.