Multitasking
- piranha
- Member

- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: Multitasking
Well, I would suggest some form of exactly what you are doing...
-JL
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: Multitasking
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
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?
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?
YouTube:
http://youtube.com/@AltComp126
My x86 OS/software:
https://sourceforge.net/projects/api-simple-completa/
Donate to get more food/programming resources/computers:
https://www.paypal.com/donate/?hosted_b ... QS2YTW3V64
http://youtube.com/@AltComp126
My x86 OS/software:
https://sourceforge.net/projects/api-simple-completa/
Donate to get more food/programming resources/computers:
https://www.paypal.com/donate/?hosted_b ... QS2YTW3V64
Re: Multitasking
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
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.
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
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.
EDIT:
It's generating a GPF, my bad.
- piranha
- Member

- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: Multitasking
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.oib111 wrote:Anyone?
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: Multitasking
What information do you need specifically?piranha wrote: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.oib111 wrote:Anyone?
-JL
- piranha
- Member

- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: Multitasking
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
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: Multitasking
Spoonfeeding, please go learn then come back with specific questions, and debug thoroughly before replying.

