Page 1 of 1

How many stacks in PMODE??!!?

Posted: Mon Feb 11, 2002 12:00 am
by chatamballi
Hi,
I have written a small PMode code in assembly.
I am able to multitask two tasks using the timer
interrupt(interrupt handler is also a task).

Right now, the tasks are really simple and
everything has privilage level=0. I want to make
my tasks execute in ring 3! I am not very clear
about the stack here. How many stacks will there?
Can someone give me a broad picture please!

regards,
Kashyap

RE:How many stacks in PMODE??!!?

Posted: Tue Feb 12, 2002 12:00 am
by OS_Dreamer
While you are talking about privilage levels, can somebody
explayne me what those are ?

RE:How many stacks in PMODE??!!?

Posted: Tue Feb 12, 2002 12:00 am
by J. Weeks
>On 2002-02-11 23:48:58, chatamballi wrote:
>Hi,
>I have written a small PMode code in assembly.
>I am able to multitask two tasks using the timer
>interrupt(interrupt handler is also a task).

Yep.

>Right now, the tasks are really simple and
>everything has privilage level=0. I want to make
>my tasks execute in ring 3! I am not very clear
>about the stack here. How many stacks will there?
>Can someone give me a broad picture please!

As a general rule, I'd have a separate stack for
each process. Myself, I use the same stack segment
for each process... but through paging, each
process still uses separate memory for their stacks.

For simplicity, I'd just give each process their
own tiny stack for now, just to see if you can
get everything up and running.

What result do you get, btw? Have you narrowed
down where the problem is yet?

Jeff

RE:How many stacks in PMODE??!!?

Posted: Tue Feb 12, 2002 12:00 am
by J. Weeks
>On 2002-02-12 05:40:05, OS_Dreamer wrote:
>While you are talking about privilage levels, can somebody
>explayne me what those are ?

Soo... you're writting an OS, eh?

Well, they're refered to as rings in intel's manuals,
and are used for process security (thus "protected"
mode). The OS runs at ring 0, and applications,
perhaps on ring 2, or 3 (it's your call, of course).

As a general rule, processes running in a lower
privelaged ring (higher numerically) cannot
access services (code, data, whatever) of
processes in a higher privelaged ring (lower
numerically).

This can be overrided with call gates and the likes,
of course.

You might want to read the intel manuals, or at least
check out a pmode tutorial before coding...

Jeff

RE:How many stacks in PMODE??!!?

Posted: Tue Feb 12, 2002 12:00 am
by The Legend
>On 2002-02-12 09:37:58, J. Weeks wrote:
>>On 2002-02-12 05:40:05, OS_Dreamer wrote:
>>While you are talking about privilage levels, can somebody
>>explayne me what those are ?
>
>Soo... you're writting an OS, eh?
>
>Well, they're refered to as rings in intel's manuals,
>and are used for process security (thus "protected"
>mode). The OS runs at ring 0, and applications,
>perhaps on ring 2, or 3 (it's your call, of course).
>
>As a general rule, processes running in a lower
>privelaged ring (higher numerically) cannot
>access services (code, data, whatever) of
>processes in a higher privelaged ring (lower
>numerically).
>
>This can be overrided with call gates and the likes,
>of course.
>
>You might want to read the intel manuals, or at least
>check out a pmode tutorial before coding...
>
>Jeff

Well I understood why Ring 0 and 3 exist, but I don't
see the real use for Ring 1 and 2 ...

RE:How many stacks in PMODE??!!?

Posted: Tue Feb 12, 2002 12:00 am
by J. Weeks
>Well I understood why Ring 0 and 3 exist, but I don't
>see the real use for Ring 1 and 2 ...

Well, again, it's your call. You don't even
have to use all the rings if you don't want.

Typically, os drivers are used on either ring 1
or 2. I believe I remember hearing of some OSs
have two different levels of drivers, one
on ring 1 (such as those highly integrated into
the OS) and the others at ring 2. Perhaps the
drivers at ring 2 were just an easier to use
interface to the ring 1 drivers (in other words,
ring 2 would call ring 1 services... not exactly
the fastest way to do it, but...)

Jeff

RE:How many stacks in PMODE??!!?

Posted: Tue Feb 12, 2002 12:00 am
by Guest
Okay, so as you add more rings (which you'll probably
only need ring 0 and 3), you'll need to have a
seperate stack per thread per ring. This is where
it starts to get a little complicated, because
even if you aren't using the x86 tss facility, you
have to have at least one tss structure around to
fill out the ring0 stack pointer, so that when
you take an interrupt or fault while in ring 3, it'll
know which stack to switch to before dumping the
iframe.

Anyway, so the end result is while you're in user
mode (ring 3), you'll be running on one stack, and
that one can be relatively large and demand paged,
and when you take a int or a fault, it'll switch
to another stack (ring 0), which should probably
be as small as possible, because it can't be demand
paged, and that's where you'll do your kernel work.

If you add more priviledge levels (which I don't
recommend), you'll need a seperate stack per thread
for every level.

Travis Geiselbrecht
http://newos.sf.net/

>On 2002-02-11 23:48:58, chatamballi wrote:
>Hi,
>I have written a small PMode code in assembly.
>I am able to multitask two tasks using the timer
>interrupt(interrupt handler is also a task).
>
>Right now, the tasks are really simple and
>everything has privilage level=0. I want to make
>my tasks execute in ring 3! I am not very clear
>about the stack here. How many stacks will there?
>Can someone give me a broad picture please!