I recently tried implementing a scheduler in my operating system (
github here) and it works fine for the first "pass" over the linked list (its a round robin design). On the second pass however, this is where I get random errors. Sometimes EIP is a very small value, sometimes very large, sometimes I get a #UD exception, sometimes #GP. Its very bizzare. I've tried everything from fixing a bug in the alloc_page() function to writing pusha/popa macros instead of using the instructions. Some help/guidance would be nice, I'll gladly provide extra logs from the serial console if it can help
Code: Select all
kernel is running
kernel is running
...
kernirq: 32
task 2
...
tasirq: 32
task 1
...
tasirq: 32
el is running <------ picked up where kernel_task left off!
kernel is running
...
kernel is rirq: 32
exception: 6
CS=8
EIP=35
Error code=0
Exception message: Invalid opcode
From this output of the different tasks running and switching, I can tell that kernel_task is switching correctly and the pit is firing correctly. But at the end when it goes from kernel_task (root of linked list) to task2 (second node) an exception occurs as described above (#UD, #GP, depends on how the computer is feeling

)
Additional notes: behavior is still random when I use the same build.