Confused with task switching. What am I thinking wrong ?
Posted: Wed Jul 08, 2009 6:54 am
Hello,
I have great trouble understanding something about the software task switching. I read a lot of tutorials and all the threads in here, but nothing could enlighten me.
This is how I currently understand the thing.
In each process page directory, I have code, data, and stack areas. Also, I have a page allocated for the kernel stack which address is contained in the TSS I set up. This address is the same in all the page directories of all the processes; in other words, for every process, a kernel stack is located at virtual address 0xwhatever.
Let's say I'm in ring0. Here comes the clock interruption, in which I'm supposed to switch task. Since I just got an interrupt, my stack has been changed to the one in the TSS right ? I go through my linked list of tasks, and finds the next one to execute.
Now I got a real problem: I have to push some registers and IRET on the task. But before iret'ing, I have to switch the page directory to the task's one ! But if I change the page directory, I won't be able to address the values I pushed before, since the virtual address of esp now points to another physical one.
I feel that I got something wrong, but I can't see what.
Thanks a lot
I have great trouble understanding something about the software task switching. I read a lot of tutorials and all the threads in here, but nothing could enlighten me.
This is how I currently understand the thing.
In each process page directory, I have code, data, and stack areas. Also, I have a page allocated for the kernel stack which address is contained in the TSS I set up. This address is the same in all the page directories of all the processes; in other words, for every process, a kernel stack is located at virtual address 0xwhatever.
Let's say I'm in ring0. Here comes the clock interruption, in which I'm supposed to switch task. Since I just got an interrupt, my stack has been changed to the one in the TSS right ? I go through my linked list of tasks, and finds the next one to execute.
Now I got a real problem: I have to push some registers and IRET on the task. But before iret'ing, I have to switch the page directory to the task's one ! But if I change the page directory, I won't be able to address the values I pushed before, since the virtual address of esp now points to another physical one.
I feel that I got something wrong, but I can't see what.
Thanks a lot