>> First of all, if it did, then every thread would require at least extra 4096 bytes, i.e. one physical page >>(plus one more page for page directory - more on it below) just in order to map GDT, while all GDT >>entries, apart from 0x30th, one are the same for all threads and processes.
The GDT is nonpaged and is per-CPU.
And??? Please note that you cannot make PTE describe less than a page. Therefore, if every page directory had its own copy of GDT that maps to the same virtual address but refers to different physical pages the way Tim originally described it (it can be done only via page directory and PTEs), you would have to waste a page of RAM for each page directory
The entries for the FS segment - both for user and kernel mode - are updated on each
context switch on this CPU.
What is the point of updating kernel FS which points to Processor Control Block, i.e. per-CPU structure that, apart from other things, keeps a pointer to ETHREAD of a thread that it currently executes??? The only thing it has to update is UM FS…
> Now consider what happens when 2 threads of the same process run simultaneously on different >>CPUs, i.e. the same page directory is loaded into more than one CPU’s CR3 register at a time.
This is really so. So what? each CPU has its own GDT.
Imagine what happens if all threads have TEB at the same virtual address under these circumstances - you would have to give every thread its own page directory in order to avoid collisions and sharing violations…
>have described would be giving every thread its own page directory
This is not done so.
Of course not - what is the point of wasting memory for nothing??? However, in order to do things the way Tim originally described you would need page directory for every thread, plus an extra page that
describes GDT, which would be pretty unwise approach…
Anton Bassov