Preemptive Multitasking?
Posted: Thu Feb 08, 2007 12:20 am
My OS currently is using a co-operative multitasking system. However, I don't like it very much, it doesn't give me much control. However, when I try out preemptive multitasking, based on the timer interrupt, it doesn't work.
My timer ISR basically pops the IP off the stack into a register, then jumps to my function ('resched'). Resched then saves the current state (including the popped IP) then jumps to the next task's IP.
This works when I am using cooperative multitasking, but preemptive multitasking doesn't work at all . Any ideas? (The OS is written purely in NASM).
Note: I run this in Bochs, the scheduler prints out the value of SI (CS) and DI (IP) as well as the first task's IP (p1) and the second's (p2). Snapshot:
The - and + are scheduler printed, the Z's and A's are the tasks.
You can see that the IP's of the two tasks have been really wrecked by something.
Any ideas?
My timer ISR basically pops the IP off the stack into a register, then jumps to my function ('resched'). Resched then saves the current state (including the popped IP) then jumps to the next task's IP.
This works when I am using cooperative multitasking, but preemptive multitasking doesn't work at all . Any ideas? (The OS is written purely in NASM).
Note: I run this in Bochs, the scheduler prints out the value of SI (CS) and DI (IP) as well as the first task's IP (p1) and the second's (p2). Snapshot:
Code: Select all
si:80=di:1486=p1:1486=p2:1550
-ZAAAAAAAAAAAAA
si:61440=di:65247=p1:58347=p2:35080
+AAAAAAAAAAAAAAAAAAAAAAAAAA
You can see that the IP's of the two tasks have been really wrecked by something.
Any ideas?