For the second question, you just build your GDT entries with the highest privelege, then you switch to protected mode.
For the second question, you just build your GDT entries with the highest privelege, then you switch to protected mode.
The OS (or loader) is responsible for setting up descriptors and managing memory. In 64-bit and most 32-bit kernels, segmentation is basically not used anymore, and the descriptors are just flat address spaces (all start at 0, no limit) with different privilege levels.
Example of 32 bit flat GDT:
0000 (null descriptor; reserved by hardware and can't be used)
0008 kernel code (ring 0)
0010 kernel data (ring 0)
0018 user code (ring 3)
0020 user data (ring 3)
0028 TSS (hardware defined structure)
Isolation between processes would then be done through the page mapping mechanism. This is kind of hard to wrap your head around at first, but makes it much easier to allocate memory. One big problem with using segments instead of fixed-size pages is that when you need to free them in some random order, memory becomes fragmented.But you can also have segments in addition to paging, which is helpful for transitioning from/to 16-bit mode.
Hope that helps at least a little bit!
What I meant was the code segment register gets reloaded to some offset in that GDT that has those protection bits set to 0. According to your flat address space map above that would be at offsets 0008 and 0010. That makes a lot of sense, thanks.