6

I understand that both tables contain segment descriptors that provide access details for each segment, including the base address, type, length, access rights ...etc.

Looking at this blog describes the differences as follows:
1. GDT have only one copy in system while LDT can have many
2. GDT may not changed during execution which LDT often changes when task switches
3. entry of LDT is save in GDT. Entries in GDT and LDT have the same structure.

How does the system use these structures differently in an actual program?

cadaniluk
  • 15,027
  • 2
  • 39
  • 67
Abundance
  • 1,963
  • 3
  • 24
  • 46

1 Answers1

7

The GDT is used to store memory blocks containing supervisor code, such as interrupt/exception handlers, and the blocks used by the kernel itself, so they are system-wide.

OTOH, a multitask OS must store where in memory the memory blocks that comprise a specific task are located. For that, a separate LDT can be used per task. Switching process involves loading a different LDT into the LDTR register.

Each task can see the memory blocks whose descriptors are, either referenced in the current LDT, or in the GDT. For user mode memory access, it will use local descriptors. For system calls, it can use various techniques, for example the INT instruction. This instruction effectively jumps to a code resident in a descriptor from the GDT. I can't remember if call gates are specific to GDT or they can be used in LDT too.

mcleod_ideafix
  • 11,128
  • 2
  • 24
  • 32
  • Can we understand that GDT is the equivalent of kernel mapping in paging system? – Oualid Mar 13 '21 at 18:11
  • GDT and LDT is used for segment mechanism. You may refer to this lecture: https://www.youtube.com/watch?v=GoI8xYCESiw – Jesse Mar 01 '22 at 12:54