Multitasking? [Sort of Fixed]
Posted: Sat Feb 03, 2007 9:53 pm
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.
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.