Sunday, February 16, 2014

Virtual address of a Process

One of the challenges of memory management is that if all processes had equal and unrestrained access to physical memory, they could interfere with each other and the system as a whole. To solve this issue, modern operating systems control which process gets what parts of physical memory via virtual memory. On the OS that implements virtual memory, a process can only access its own memory. It cannot access the memory of other proccesses or the OS itself. The CPU, in concert with the OS, enforces these restrictions.

Each process has its own independent view of the entire virtual memory space. The process' virtual memory space is divided into pages. For x86, these pages are typically 4KB in size. Some pages might be immediately available in physical memory; others might have been temporarily stored("swapped" or "paged") by the OS to disk. This allows the sum total of memory usage by processes to exceed the total physical memory.

Each process has tables that map pages; these page tables are set up by the OS at process start, and provide the ability to translate virtual addresses into physical addresses. A virtual address can be looked up inn the processes' page table- if the page is present, the OS returns the associated physical address. If the page is not present, the OS will receive a Page Fault, at which point it can read the data from disk.

No comments:

Post a Comment