Hi,
Rogator wrote:What is the purpose of using an LDT? Could one not just have a GDT with all the needed entries? (null, ring 0 flat code and data, ring 3 flat code and data, tss)
IMHO the LDT was meant for environments that use segmentation. The idea being that you use the GDT for things that are used by all software (e.g. the kernel's segments) and an LDT for each process. For example, you could have an OS where the LDT is changed every task switch and processes allocate
segments of memory, rather than pages of memory.
Most OS's don't use segmentation though, so the LDT isn't used. It would be possible to use a single LDT for all software, which is something I've done before - the GDT was mostly used for TSS's (hardware task switching) and the LDT was used for code segments (with flat 4 GB data segments).
Rogator wrote:Would it be correct term-wise to say that a page is virtual, and is mapped to a page frame, which is physical, and thus when allocating physical memory one allocates page frames?
I'd say there's physical pages which exist in the physical address space, and virtual pages which exist in the virtual/linear address space. A virtual page might be associated with a physical page, but it might be associated with part of the swap space, or part of a memory mapped file or something else (or nothing for allocation on demand).
IMHO you couldn't say "a page is virtual, and is mapped to a page frame" because the page is a physical page before it's mapped into the page frame. Something like "a physical page is mapped into a page frame to become a virtual page" would be more correct. Also physical pages are used for page frames, but there isn't a one-to-one relationship - you don't have a page frame for each page allocated.
Also it's possible (although much less common and it does depend on the OS's design) for physical memory to be allocated for other purposes (not virtual memory). This could include page tables and page directories, but could also include other data structures used only by the kernel when paging is disabled. For example, you could have an OS where the kernel uses the first 4 MB of each virtual address space, and disables paging to access additional data (so that processes can use 4092 Mb of virtual memory).
Anyway, I'd rewrite the above as:
A physical page is mapped into a page frame to become a virtual page, and thus when allocating physical memory to be used for virtual memory one may need to allocate additional physical pages to be used as page frames.
I can be fairly pedantic at times though, and it'd depend what this sentence was to be used for...
Cheers,
Brendan