Context switching for MT
Posted: Wed Oct 05, 2011 10:01 am
Hi,
I am currently working on a multitasking implementation.
Somebody told me "just switch esp .."
So I wrote an ASM-Subroutine which is:
and call it like this:
but this doesn't work System stands still ..
I also tried this:
to test if the asm routine is the problem, or a wrong esp .. but this doesn't work either ..
Could someone give me a hint, what could be the problem?
I am currently working on a multitasking implementation.
Somebody told me "just switch esp .."
So I wrote an ASM-Subroutine which is:
Code: Select all
global _switch_task
_switch_task:
pop eax
pusha
xchg esp, eax
popa
ret
Code: Select all
uint32_t nextESP = ...
switch_task(nextESP)
I also tried this:
Code: Select all
uint32_t curESP;
asm ( "mov %%esp, %0;" : "=r"(curESP));
switch_task(curESP);
Could someone give me a hint, what could be the problem?