I am currently trying to create ring 3 tasks. I did not understand a paragraph in the tutorial available on the wiki, which is:
In the interruption code, I understand that the current stack is the one TSS.ESP0 points to. Since multitasking is implemented with the clock interruption, switching from task to task implies that I am in this situation. But now, what's the meaning of the bold sentence ? How come the "other task's esp" is the same esp0 stack ? Can someone enlighten me ?
Multitasking considerations
There are a lot of subtle things with user mode and task switching that you may not realize at first. First: Whenever a system call interrupt happens, the first thing that happens is the CPU changes to ESP0 stack. Then, it will push all the system information. So when you enter the interrupt handler, your working off of the ESP0 stack. This could become a problem with 2 ring 3 tasks going if all you do is merely push context info and change esp. Think about it. you will change the esp, which is the esp0 stack, to the other tasks esp, which is the same esp0 stack. So, what you must do is change the ESP0 stack (along with the interrupt pushed ESP stack) on each task switch, or you will end up overwriting yourself.
Lionel