I'm writing a multitasking system (in NASM assembly). So far, it just has 2 predefined 'tasks' to test out the system. Later, it will allow a custom number of procedures.
The scheduler runs on the timer interrupt (using preemption). When it needs to reschedule, it pops the CS and IP off the stack (which was pushed on when the interrupt was called). It then calls resched which saves and restores the register states. It then takes the popped CS and IP and than jumps to that location.
The problem is, none of the code in the procedures actually runs. It just hangs when it needs to jump to the procedure. Any ideas?
Note: I'm using real-mode by the way.
Update: Now the scheduler is working properly, but after the first 'reschedule' no more timer interrupts fire, effectively stopping the OS from multitasking.
Update 2: I've taken out the whole preemptive scheduler and replaced it with a cooperative scheduler. It works much better for the type of system I'm writing. Of course, if anyone can help me write a preemptive scheduler I'll be much happier.
Multitasking? [Sort of Fixed]
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
OK, the scheduler now works, sort of. The problem is that the scheduler overwrites the other procedure's IP restore value. Is there any way I can stop this from happening?
Update: Found the problem: whenever the interrupt fires, when I pop the IP off the stack, it is an incorrect value. Any help in this matter would be great.
Update: Found the problem: whenever the interrupt fires, when I pop the IP off the stack, it is an incorrect value. Any help in this matter would be great.