0

how will translation of address take place in user mode? if user has a separate page table, then where are these stored? Moreover, how will the user access page tables stored in kernel address space in a system having hardware page table walk mechanism?

2
  • I do not think user can work directly with those addresses and pages. User make system call to the kernel. Nov 22, 2019 at 10:38
  • thank you for reply. actually my doubt is that if i am working in user mode, then how will the virtual address be translated to physical address because in one of the links i read that page tables are stored in kernel address space and as per my understanding, user can not access kernel space. so how will the translation take place and how a hardware page table walker will walk the page table in this scenario? Nov 22, 2019 at 12:24

1 Answer 1

0

The kernel sets up the page tables for each process. The mapping from virtual to physical addresses is done by the memory management unit (MMU) in hardware. This is done transparently to user mode code. User mode does not change the page tables, and they are only visible to the kernel.

The process's virtual address space is divided into areas with differing properties: some areas are read-only, some read-write, and typically most virtual addresses have no mapping at all. Access violations are handled by the kernel. For example, when a process accesses a memory location that has no mapping to a physical memory frame, an exception is raised . This exception (trap) is handled by kernel code, which can kill the process, send a signal to it, or the kernel can transparently create a mapping for the page.

Transparently (to the user mode code) mapping a page can happen because the page has been swapped out. In this case the so called page fault handler maps the page to a free physical RAM frame, and arranges for the page to be read in from swap space. When the page has been restored, the process is scheduled to run again, and the process can continue execution as if nothing had happened.

2
  • Thanks for replying. So what you are saying is that the page tables for user mode are stored in kernel address space and they are read only for user mode???? Nov 24, 2019 at 1:25
  • The page tables are not accessible (i.e. not readable) at all from user mode, and user mode does not need to access them. Memory management is handled transparently to user mode, you don't need to include code in your application programs that handles page tables. The situation is the same as with process scheduling: scheduling is handled by kernel invisibly to the user mode program. The idea is to provide resources like CPU and memory to processes as if they were the only running program on the machine. Nov 25, 2019 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .