GDT

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
Destiny

GDT

Post 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 ????
Warmaster199

Re:GDT

Post 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...
Tim

Re:GDT

Post 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.
Destiny

Re:GDT

Post 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..
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:GDT

Post 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)
Post Reply