0

I have read that in XV6, in every process virtual address space entire physical address space is mapped. How is that even possible?

1 Answers1

0

I have read that in XV6, in every process virtual address space entire physical address space is mapped. How is that even possible?

Typically virtual address spaces are split into 2 areas - user-space (belonging to the current process) and kernel-space (same for all processes). Kernel-space is then split into smaller areas (kernel's code & data, areas for memory mapped devices, etc). If the remaining amount of kernel space is large enough to hold the entire physical address space, then there's no problem (but this is extremely unlikely).

However; this probably isn't what XV6 actually does. Far more likely is that it only maps physical RAM into kernel space (and does not map the entire physical address space at all).

For some real numbers; assume you have a computer with 128 MiB of RAM and a 32-bit CPU with 4 GiB of physical address space (where most of the physical address space is unused and isn't RAM); and you also have 256 MiB of kernel space left over. In that case, 128 MiB of RAM would fit in the remaining 256 MiB of kernel space (but the whole 4 GiB of the physical address space will not).

Of course this is still likely to fail on real systems (whenever there's too much RAM, and especially for 32-bit CPUs). Fortunately XV6 is only for "educational purposes" and isn't expected to actually work on real computers, so that's not a major problem.

Brendan
  • 35,656
  • 2
  • 39
  • 66
  • correct me if I am wrong. I am assuming physical space and RAM are same and kernel address space will be inside physical address space besides processes address space – Rohit Reddy Nov 26 '20 at 13:20
  • @RohitReddy: Physical address space contains RAM, plus ROM, plus various memory mapped devices, plus extra unused space (for future expansion, etc). For modern 80x86 CPUs typically (it varies depending on which CPU) physical addresses are 48 bit which would work out to 256 TiB of space, but RAM is often 32 GiB or less (smaller than 1% of physical address space). – Brendan Nov 26 '20 at 22:58