Helo a relative newbie figure out software task switching
Posted: Wed Jul 03, 2002 11:00 pm
I've been working on a simple OS (code at keyos.sf.net), and I've gotten a few things done. I'd like to figure out how to do software task switching on x86, since I hear that it is faster and easier than hardware TSS-based switching.
So I have a simple function which should switch between two tasks:
;C prototype is void context_switch(unsigned int **old_esp, unsigned int *new_esp);
context_switch:
pushad
mov eax, [esp + 36]
mov [eax], esp
mov eax, [esp + 40]
mov esp, eax
popad
retn
...but when I call that, I get an int13 (general protection exception). I think it is because I'm passing an invalid old esp. Also, I've done nothing to set up the stacks of either thread... they are simply 4k chunks of memory.
I'm sure I'm doing a zillion things wrong, might someone help me figure this out?
So I have a simple function which should switch between two tasks:
;C prototype is void context_switch(unsigned int **old_esp, unsigned int *new_esp);
context_switch:
pushad
mov eax, [esp + 36]
mov [eax], esp
mov eax, [esp + 40]
mov esp, eax
popad
retn
...but when I call that, I get an int13 (general protection exception). I think it is because I'm passing an invalid old esp. Also, I've done nothing to set up the stacks of either thread... they are simply 4k chunks of memory.
I'm sure I'm doing a zillion things wrong, might someone help me figure this out?