Page 2 of 2
Re: Multitasking
Posted: Sat Mar 27, 2010 2:56 pm
by oib111
Such as?
Re: Multitasking
Posted: Sat Mar 27, 2010 3:00 pm
by piranha
Well, I would suggest some form of exactly what you are doing...
-JL
Re: Multitasking
Posted: Sat Mar 27, 2010 3:11 pm
by oib111
Ok, well so I have my function to switch between tasks. And near the end is when it starts loading in the new values for the registers, for the new task, but when I try to load in the new value for ebp it causes an invalid opcode exception.
Re: Multitasking
Posted: Sat Mar 27, 2010 3:20 pm
by ~
If you still have pending stack tasks that require the EBP value, that could happen. Maybe there could be problems with segment registers, but it will be specific to your code.
What if you try to reload EBP only when you are finished loading every other value and no more local stack operations are needed, and leave the EBP to be the last element (or almost last) to be reloaded?
Re: Multitasking
Posted: Sat Mar 27, 2010 3:32 pm
by oib111
The very last thing I do is push the new cs and eip onto the stack and do a retf instruction. So even if I loaded in the new ebp right before that there'd still be stack operations.
Re: Multitasking
Posted: Sat Mar 27, 2010 3:43 pm
by Gigasoft
Shouldn't CS always be set to the same value inside the kernel? I have a hard time believing that functions that call the task switching function will have a different CS than the task switcher itself.
If EBP points to the save area, you should push the new EIP before loading EBP. Another solution would be to just leave EIP on the stack when switching tasks, so that you don't have to push it later.
Re: Multitasking
Posted: Sat Mar 27, 2010 3:48 pm
by oib111
Inside the kernel CS is always the same, but when Ring 3 tasks are preempted then there's going to be a switch to the kernel and then the CS will change, so when switching back to Ring 3 for the new task you need to change CS...right?
EDIT:
It's generating a GPF, my bad.
Re: Multitasking
Posted: Sun Mar 28, 2010 1:23 pm
by oib111
Anyone?
Re: Multitasking
Posted: Sun Mar 28, 2010 4:35 pm
by piranha
oib111 wrote:Anyone?
No one is going to help you unless you give us enough information to come up with a theory as to why it doesn't work.
-JL
Re: Multitasking
Posted: Sun Mar 28, 2010 4:58 pm
by oib111
piranha wrote:oib111 wrote:Anyone?
No one is going to help you unless you give us enough information to come up with a theory as to why it doesn't work.
-JL
What information do you need specifically?
Re: Multitasking
Posted: Sun Mar 28, 2010 5:03 pm
by piranha
Well, all you've told us is some stuff about CS, a couple of asm operations you do, and that you get a GPF. Maybe....some code...some more info...
-JL
Re: Multitasking
Posted: Sun Mar 28, 2010 5:08 pm
by JamesM
Spoonfeeding, please go learn then come back with specific questions, and debug thoroughly before replying.