Page 1 of 1

Virtual memory management

Posted: Fri Sep 22, 2017 11:00 am
by Coconut9
I will load my kernel at physical address 0xC0000000, I will map the virtual kernel address to the same value (0xC0000000) and I will start some programs. All my interrupt handlers will work virtual addresses right? Do I will have any problem (something extra to do) using multiprocessor? I am thinking memory like this (ex):

Code: Select all

Physical memory                                                 Programs 1 Virtual memory                                       Programs 2 Virtual memory
0x00000000-0x00000FFF program1                                  0x00000000-0x00000FFF program1                                  0x00000000-0x00005FFF program2.1
0x00001000-0x00001FFF file1                                     0x00001000-0x00001FFF file1                                     0x00006000-0x00007FFF program2.2
0x00002000-0x00003FFF physical memory bitmap                    0x00002000-0x00002FFF file4                                     0x00008000-0x00008FFF file 2
0x00004000-0x00009FFF program2.1                                0x00003000-0xBFFFFFFF undefined                                 0x00009000-0x00009FFF file 3
0x0000A000-0x0000AFFF file2                                     0xC0000000-0xC000FFFF kernel                                    0x0000A000-0xBFFFFFFF undefined 
0x0000B000-0x0000CFFF program2.2                                0xC0010000-0x0003FFFF kernel data                               0xC0000000-0xC000FFFF kernel
0x0000D000-0x0000DFFF file3                                     0xC0040000-0xC0041FFF physical memory bitmap                    0xC0010000-0x0003FFFF kernel data 
0x0000E000-0x0000EFFF free                                      0xC0042000-0x00049FFF VGA                                       0xC0040000-0xC0041FFF physical ...
0x0000F000-0x0000FFFF file4                                     0xC004A000-0xFFFFFFFF undefined                                 0xC0042000-0x00049FFF VGA
0x00010000-0x0004FFFF free                                                                                                      0xC0042000-0xFFFFFFFF undefined
0x00050000-0x0007FFFF kernel data
0x00080000-0x000B7FFF free
0x000B8000-0x000BFFFF VGA
0x000C0000-0xBFFFFFFF free
0xC0000000-0xC000FFFF kernel
0xC0010000-0xFFFFFFFF free
Is it correct (of course the kernel virtual pages will be set as not user access pages)?

Re: Virtual memory management

Posted: Fri Sep 22, 2017 8:23 pm
by Brendan
Hi,
ARISTOS wrote:I will load my kernel at physical address 0xC0000000,
No, you won't - it's very unlikely that there's RAM at physical address 0xC0000000 (even on computers with 4 GiB or more RAM) because this area is typically used for memory mapped PCI devices.
ARISTOS wrote:I will map the virtual kernel address to the same value (0xC0000000) and I will start some programs. All my interrupt handlers will work virtual addresses right?
Almost everything in the entire OS uses virtual addresses, which means that physical addresses are almost always relatively irrelevant - they only matter very early during boot and for some device drivers (for devices that use DMA and bus mastering).

For an example of how much physical addresses don't matter; my boot loaders set up a temporary physical memory manager and then use it to allocate "deliberately randomised for security purposes" physical pages for everything else. I literally can't know/predict which physical addresses my own boot loader will load my kernel into.
ARISTOS wrote:Do I will have any problem (something extra to do) using multiprocessor?
For memory management, multiprocessor often doesn't involve anything extra (beyond locks/spinlocks/mutexes to make sure 2 or more CPUs don't confuse each other when using the same data at the same time).


Cheers,

Brendan