0

I have noticed that when I open two processes with GDB for debugging, /proc/PID/maps indicate the same address regions for the two :

cat /proc/4170/maps
555555554000-555555555000 r--p 00000000 08:01 655807                     /home/user/1
555555555000-555555556000 r-xp 00001000 08:01 655807                     /home/user/1
555555556000-555555557000 r--p 00002000 08:01 655807                     /home/user/1
555555557000-555555558000 r--p 00002000 08:01 655807                     /home/user/1
555555558000-555555559000 rw-p 00003000 08:01 655807                     /home/user/1

cat /proc/4177/maps
555555554000-555555555000 r--p 00000000 08:01 664427                     /home/user/2
555555555000-555555556000 r-xp 00001000 08:01 664427                     /home/user/2
555555556000-555555557000 r--p 00002000 08:01 664427                     /home/user/2
555555557000-555555558000 r--p 00002000 08:01 664427                     /home/user/2
555555558000-555555559000 rw-p 00003000 08:01 664427                     /home/user/2

I don't understand how this is handled, I thought each process should have its own page table ?

0

I don't understand how this is handled, I thought each process should have its own page table?

This is exactly what’s happening here. The addresses in /proc/.../maps are virtual addresses, not physical addresses; they are interpreted through each process’s page tables, so that processes get separate pages in physical memory (except for shared pages).

Thus both processes have writable memory available at virtual addresses 555555558000-555555559000, but each process has a different page table for that memory, ultimately pointing to different physical addresses.

(I’m simplifying a little, there are additional subtilities for e.g. copy-on-write etc. but we can ignore that here.)

1
  • Actually I thought that the virtual address contains some bytes that indicate the page table offset, like what I saw in the Intel manual. Is this wrong ? – Aramya Mar 30 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.