Page 1 of 1

GDT

Posted: Sat Aug 31, 2002 3:03 pm
by Destiny
Hi,

Why does every boot code i've seen limit GDT at startup to 768 ??? IDT is limited to 256 that's ok because the Intel Architectur (x386) only knows 256 interrupts .. but what about GDT why 768 ????

Re:GDT

Posted: Sat Aug 31, 2002 4:11 pm
by Warmaster199
You only really need 5 descriptors for a simple O.S. A NULL, CS(kernel code), DS(kernel data), ES(user code), FS(user data). If your OS is multitasking, then I believe that you need additional descriptors in the GDT for each TSS(Task State Segment). For start-up, that is enough. Later on is when you reset the GDT, if you want/need more. Then, the GDT may have up to 2048 entries. 768 entries is a large amount, I don't see for a need for more than that. Major OS'es such as LINUX only have 64 processes running at once...

Re:GDT

Posted: Sun Sep 01, 2002 5:10 am
by Tim
In reality the limit on the size of the GDT won't matter, because you probably won't be using hardware task switching, and so there will only be one TSS per CPU. This is what major OSes like Linux and NT do.

Re:GDT

Posted: Sun Sep 01, 2002 8:22 am
by Destiny
Thanks for ya help , but why I shouldn't use the hardware support, I think it's much faster than doing all by yourself..

Re:GDT

Posted: Mon Sep 02, 2002 1:08 am
by Pype.Clicker
There is another reason why you could need more descriptors if you want to achieve more evoluted protection than linux does (for instance, giving a separate stack segment to every kernel thread so that a stack overflow doesn't corrupt datas, etc.) or if you want to give every process a separate LDT and GDT (Linux actually gives every CPU one TSS and performs purely software switching, which becomes costly when you have to swap the I/O map)