Quote:
Hi!
I've some doubts (two, by now
)
1) The IDEA:
?...
?save_current_context(return_point);
?load_others_task_context();
?return_point:
?...
?
When you save the current context you have to save a value for EIP that must be AFTER the load context procedure, so you use return_point.
2) I'm tring to do this without using the INTEL processor facilities (TSS,etc.), would it be very difficult?
Thanks!
Actually, it's not difficult at all. The most common way of doing that is by switching stacks. You write an interrupt routine for the scheduler. This routine pushes all registers of the current task to the stack, then it saves current values of SS and (E)SP in some array, loads SS and (E)SP of the other task, pops all registers and issues IRET. So to switch tasks you just make an INT xx call and that's it. The only thing you should do besides this scheduler thing, is some routine that would prepare stack contents for a new task (e.g. would "push" (E)FLAGS+CS+(E)IP and other registers to the new stack and save resulting SS:(E)SP so that the scheduler gets the required information from that array easily and does not make any data processing.