This is my second topic in this forum, after a year I returned to my hobby OS.
I started working on multitasking, all seems to work, at least partially, but I realized that when... Let me explain a bit.
My multitasking code is very simple:
-Timer interrupt arrives
-IRQ handler pushes all registers
-Selects a process from “ready tasks”
-Gets registers(cpu state) from selected task and returns them
-Again, in the IRQ handler it does a stack swap
How does it select a process:
-I have a one-way linked list of processes.
-Two pointers, one to the first task(the head) and the other to the last task in the list(the tail)
-For each switch I select the next task(forward in the list)
-If there is no “next”, then I select the first task again
The problems comes here, when I return to the first task(in my example is the idle task), so I get a page fault with this state before the interrupt is raised.
Code: Select all
Cause of exception: Page fault
Interrupt Number:0x0000000E
Error Code:0x00000000
EFLAGS:0x00000008
Segments:
DS:0x00000010 ES:0x00000010
FS:0x00000010 GS:0x00000010
Registers:
EAX:0x10400E40 EBX:0x00000000 ECX:0x0000001A
EDX:0x00000001 ESI:0x00000000 EDI:0x00000000
EIP:0x00000000
Stacks:
EBP:0x0014C83C
ESP:0x0014C80C
I do not know why my EIP becomes 0 (¿…?).
I am with this from 2 days ago. I will attach my task.c(only with important functions), I feel it is probably a silly mistake.
Thank you in advance for your help and sorry for my bad English.
EDIT: If I do not share where the code is mirrored is because of privacy reasons.