Page 1 of 1

Some questions about multitasking and VM86

Posted: Sun Feb 17, 2008 11:57 am
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

Re: Some questions about multitasking and VM86

Posted: Sun Feb 17, 2008 2:01 pm
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

Re: Some questions about multitasking and VM86

Posted: Mon Feb 18, 2008 1:27 am
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.