I'm trying to understand a few things regarding paging and segmentation...
Firstly,
- In order to implement protected mode within, Is segmentation required? could it be implemented paging?
from what I understood every code segment has some privilege level, and code that runs within it can not preform instructions higher but that brings a lot of problems up in my opinion.... for example, what if some interrupt raises while executing code that belongs to a low privilege segment, the CPU would immediately move on and start executing instructions of some ISR handler, when would the CS be swapped? how would the CPU know the code executing within it is currently of a strict segment.
- How are paging combined with segmentation specifically within the 80386 processors architecture?
I've read that within paging you also have page permissions as in R W E, and if accessing some address which is not at your permission some interrupt would be raised, so this brings, which makes segmentation issue kind off useless...
- Within memory segmentation, when context switching into kernel code, how could the CPU know that the code segment currently executing is within the highest privilege level?
This kinda makes things difficult and seems to be not really useful...
- What is 80386 actually using for memory management, and what is a flat memory model
I find a lot of problems with the memory segmentation method, for example
for example, if I'm writing some command that attempts fetching the value from the virtual memory address of 0x1234FFFF how would my processor know to which segment am I referring? perhaps I am trying to execute from 0x1234FFFF and perhaps I am trying to read from it.... how does it know when am I referring to the DS and when am I referring to the CS or the SS....?
- Doesn't 80386 have a user/kernel-bit that Is turned on once the CPU is executing within kernel-mode and off when within user-mode or some similar mechanism to create protected execution?....
I honestly find this super confusing and annoying and have a huge headache from trying to understand this... Hopefully someone could explain this to me