For example with following C code
#include <stdio.h>
int main() {
unsigned long temp = 0x12345678;
printf("temp address is %p\n", &temp);
int* func_addr = (int*)main;
printf("main address is %p\n", func_addr);
int i;
// suspend process
scanf("%d", &i);
return 0;
}
Compile the code on my machine ()and run the program in two terminals, and two process outputs:
Process 1:
temp address is 0xbfcc5350
main address is 0x80484bb
Process 2:
temp address is 0xbf94e5d0
main address is 0x80484bb
My questions are based on the figure Linear Address:
- main's virtual address are the same in two processes, and we know that virtual address equals to linear address, according to address translation from linear address and physical address, two identical virtual addresses should be mapped to two identical physical addresses, but actually two main's physical addresses are different, how is the mapping process?
- temp's addresses in two process are based on pages, their PGD part(high 10 bits) are the same (0x2ff), that means the two process has the same Page Table Entry?
My OS is Ubuntu 16.04.1 LTS, 32bit.