News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GTD/LTD's?

Started by redskull, April 08, 2006, 08:51:50 PM

Previous topic - Next topic

redskull

I was doing some reading, trying to learn myself up on protected mode CPU operation, and I hit a snag when it comes to the Global Descriptor Tables and the Local Descriptor Tables.  It's my understanding that the GDT holds descriptors that basically do just that: describe sections of memory allocated to the various taks running on the system.  However, the LDT is a little more vauage.  It seems as though a descriptor in the GDT indexes into another table, the LDT, which then points to the actual memory.  I guess what I don't really see is the need for it; it seems as though you're adding unecessary steps for memory access.  I had a thought it might be a way to further segment a tasks code/data/stack/etc, but the manual seems needlessly cryptic on the subject:

From the Intel Manual:
QuoteEach system must have one GDT defined, which may be used for all programs and tasks in the system.  Optionally, one or more LDT's can be defined.  For example, an LDT can be defined for each separate task being run, or some or all tasks can share the same LDT.

I read this to say that you can basically do things however the hell you want, but what are the advantages of either choice?  If an LDT is 'Local' only to that task, then how can 'all tasks share the same LDT'? Why would you want an LDT? Does anybody know which way Windows NT uses?  I'm not trying to write an O/S, i'm just being overly curious.  Thanls again in advance for the clarifications

alan
Strange women, lying in ponds, distributing swords, is no basis for a system of government

Gustav


> It seems as though a descriptor in the GDT indexes into another table,
> the LDT, which then points to the actual memory.

No. whether a selector refers to GDT or LDT is determined by bit 2 of the selector.
Besides that, there is not that much difference between these 2 tables. Some system segments cannot be located in the LDT, though (TSS or LDT descriptors).

> If an LDT is 'Local' only to that task then how can 'all tasks share the same LDT'?

the current LDT is hold in just one register (the LDTR) and it is up to the OS whether the value of this register is to be changed during a task switch.