Some questions about multitasking and VM86

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.
Post Reply
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Some questions about multitasking and VM86

Post by gzaloprgm »

Hello!

I'm near to start coding my software multitasking code.

For the scheduler I'll use the simple Round-robin algorithm, and in each Timer call (10ms), I'll save the actual registers and I'll load the registers from next task. (no tss)

But I think I have a problem.

AFAIK VM86 mode runs always in ring 3, so if I set up a V86 monitor that will execute the Vesa mode-switching code, how do I switch to different rings task with software multitasking?

To set a ring 3 task, Will I need a TSS per task?

Also, does anyone knows what happened to SANiK and its idea to convert 16 to 32 bits code on the fly? (http://www.osdev.org/phpBB2/viewtopic.php?t=10321 )

Thanks,
Gonzalo
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Some questions about multitasking and VM86

Post by Brendan »

Hi,
gzaloprgm wrote:AFAIK VM86 mode runs always in ring 3, so if I set up a V86 monitor that will execute the Vesa mode-switching code, how do I switch to different rings task with software multitasking?
The timer IRQ will cause the CPU to switch to CPL=0 regardless of which mode and which privilege it was running at before the IRQ. Your task switching code will always be running CPL=0 kernel code before the task switch and will be running CPL=0 kernel code after the task switch.

The only difference is the IRQ handler's stack frame (if the IRQ interrupts V86 code you get segment registers pushed on the stack), but this is irrelevant because sometimes you'll want to switch tasks without waiting for the IRQ handler first (e.g. when a task decides to "sleep()"), so you can't rely on the IRQ handler's stack frame within the task switching code.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: Some questions about multitasking and VM86

Post by xyzzy »

gzaloprgm wrote:To set a ring 3 task, Will I need a TSS per task?
You just need one TSS. Set esp0 and ss0 in it to a kernel stack pointer and kernel stack segment.
Post Reply