Does virtual address space resides in virtual memory ? I have a confusion like , Each process has its own virtual memory and page table and conversion to physical address from virtual address takes place while loading it into physical memory , but where does the virtual address space comes into picture ? I have gone through many operating systems books but everywhere it gives just explaination about particular word not where it resides and what is the relationship between them and how it operates. please just explain me theoretically , example not needed. Thanks in advance.
- 2An address space is just the set of possible (numerical) addresses. Physical address space is the set of physical-memory addresses, ditto for virtual address space. Processes deal with virtual addresses (on most platforms).Oliver Charlesworth– Oliver Charlesworth2013-12-28 21:05:52 +00:00Commented Dec 28, 2013 at 21:05
- The virtual address space (of e.g. a process) is just a datastructure (the pagetable) that tells the hardware how to translate memory addresses used when accessing memory to physical memory addresses. The currently active page table resides in physical memory, and it might be changed/switched out to provide another set of mapping whenever desired, such as providing a different set of mappings for each process.nos– nos2013-12-28 21:25:11 +00:00Commented Dec 28, 2013 at 21:25
- What is your practical programming problem? This appears to be a theoretical question, better suited to cs.stackexchange.comRaymond Chen– Raymond Chen2013-12-28 22:16:06 +00:00Commented Dec 28, 2013 at 22:16
3 Answers
(Virtual) Address space is the set of allowable addresses for a given address width (that is 2^32 bytes on x86, 2^64 on x64). Virtual memory usually means almost the same. It is the set of allowable addresses for a certain process or application or also for the whole system. The virtual memory for a single application can be at most as big as the virtual address space of the system. Each application can "see" only the virtual address space that is allocated to it by the OS (and due to some trickery, it is possible that each application can have a virtual address space of the same size and the sum might be larger than the address space of the system).
Physical memory (more correct: physical RAM), is the amount of effectively installed RAM modules. It is usually smaller than the virtual address space. The OS does swapping to bring the requires memory pages from the hard disk into the physical memory if needed. A memory page in physical memory has a physical address and a virtual one. Normal applications only see the virtual address, and they don't (and must not) care about where the memory page is physically loaded. Therefore an address seen in an application or a debugger is really a virtual address in the virtual address space of that application. The physical address is only ever needed when directly interfacing to hardware. It can even constantly change if the OS decides to do so.
Hope this makes it a bit clearer.
2 Comments
I'm not a specialist but i think virtual addressing and paging is a part of the cpu protected mode introduced after 80386 and it is not part of the operating system. The operating system controls the page tables. For the virtual addresses they are just numbers in your executable file for example objdump -d will display them
Comments
Virtual memory refers to a view of memory exposed to some code somehow.
The term virtual address space refers specifically to the addresses used to reference items (usually made up of 8-bit bytes, though memory-mapped I/O devices muddy the waters, and some devices use things other than 8-bit bytes), a subset of these addresses, to an entity that maps virtual addresses to the underlying, well, stuff, or to some layout, plan, or scheme for arranging things in virtual memory.
These are indeed so closely related that they are often used interchangeably, but one important difference is that to have a quantity of virtual memory requires that you have somewhere to keep that much data, but virtual address space just requires that it somehow be possible to map some memory at the appropriate number of addresses.