which fills the contents of the segment register based on what ?? (kernel planner?)
Boot loader. ISR and exception handlers. System call handlers. The scheduler does this. Some other parts may be needed. Registers are considered private and must be saved and restored during various context switches. And, of course, they must be initialized in the previous paragraph.
Based on what should be in these registers. Their values are not universally distributed between different parts of the OS and between different programs.
and what happens when an application changes the value of a segment register? I know that only CS cannot be changed because it has the CPL of the current CPU. but other registers (SS, DS ...) can be changed.
What's happening? It either successfully replaces it, or raises an exception (usually #GP), and then it happens regardless of what the exception handler does, or if it doesn’t work, a triple error, CPU reset and, possibly, a reboot of the whole computer.
You can change any case register if you somehow know what else can be loaded into it at the current privilege level. If your program is at level 3 and there are two code segments with DPL = 3 installed for it by the OS, the program can use any of them for the CS register. If you do not know this, you are likely to just disable the program.
I want to know the details of the registers of the x86 segment.
Get a copy and read:
Intel® 64 and IA-32 Software Developer Guide. Consolidated volumes: 1, 2A, 2B, 3A and 3B.
You can either go to the appropriate chapters (memory management, handling interrupts / exceptions, task switching), or find specific registers (for example, CS or SS or DS) or see the description and pseudo-code for specific instructions.
You will not get more accurate answers to questions that are vague.