Thanks for the response!
nullplan wrote:
For one, you can map fixed virtual addresses to dynamic physical addresses.
So that is useful for things like the LAPIC, where e.g. the pysical address could be 0x123465, but you would map it to 0xFEC0000 (or some other place).
nullpan wrote:
So for example your kernel can be loaded wherever the bootloader wants, and as long as the bootloader maps it correctly, there is little reason for your kernel to know. The BL does not even need to load the whole kernel contiguously, just make it appear contiguous in virtual memory.
So that is useful for the higher-half kernel.
nullplan wrote:
Another important use for paging is related but slightly different: You can change the mapping between processes. This means different processes can use the same address and mean different places in memory by those addresses. And they don't need to know of each other or coordinate this in any way. Finally, and this is key, you can use paging to prevent processes from seeing or modifying memory of the kernel or other processes. In DOS, one badly written application can bring down the whole system, while in more modern OSes, this is generally not possible. The offending application would crash and the rest of the system remains usable.
So if program A was at the physical address 0x1234 and B at 0x3456, they could both be mapped to virtual 0x10000 (how does this behave with multicore cpus? Can they have differing virtual memory?) during the taskswitch. Now if physical 0xff80 is mapped at virtual 0x2000 in both directories (each process has it's own page directory in this example), it can be used as shared memory.
But if the pagetable of program C does not contain the mapping of the shared memory, C can not see 0x2000 and accessing it would result in a page fault. Is this correct?
Ok, this makes sense as to why I would use paging. Thank you.