Multitasking

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Multitasking

Post by oib111 »

Such as?
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Multitasking

Post by piranha »

Well, I would suggest some form of exactly what you are doing...

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Multitasking

Post 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.
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: Multitasking

Post 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?
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Multitasking

Post 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.
Gigasoft
Member
Member
Posts: 871
Joined: Sat Nov 21, 2009 5:11 pm

Re: Multitasking

Post 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.
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Multitasking

Post 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.
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Multitasking

Post by oib111 »

Anyone?
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Multitasking

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Multitasking

Post 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?
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Multitasking

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Multitasking

Post by JamesM »

Spoonfeeding, please go learn then come back with specific questions, and debug thoroughly before replying.
Locked