Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process Address Space vs Virtual Memory

From my understanding by reading several articles I assumed Process Address Space(PAS) and Virtual Memory(VM) are same. Is my understanding flawed? Can some one please shed some light on this and en light me? I am confused.

I understand Process Address Space has nothing to do with Ram or Physical memory.

But Just confused about PAS and VM.

like image 506
Sandeep Avatar asked Nov 13 '11 03:11

Sandeep


People also ask

Is virtual address space the same as virtual memory?

Virtual memory is a memory management technique developed for multitasking kernels. Virtual address space is a memory mapping mechanism available in modern operating systems. So the answer is: yes, these are quite different terms.

What is the difference between address space and memory space?

Therefore, the address space is the set of addresses generated by programs as they reference instructions and data. The memory space holds the actual main memory locations that are directly addressable for processing.

What is processor address space?

The range of virtual addresses that the operating system assigns to a user or separately running program is called an address space. This is the area of contiguous virtual addresses available for executing instructions and storing data.

Is virtual address bigger than physical address?

On a 64-bit system, the size of the virtual address space is 264 bytes, or 24⋅10246 bytes. That's 16 exbibytes, which is about a billion times bigger than current physical memories.


1 Answers

First: "memory" is not equal to "address space". Address space is range of posible addresses. I.e. it's 4 Gb for 32-bit pointers and 16 Eb for 64-bit pointers. On the other hand, memory is... well, memory which you can actually use (at least possibly). So, I bet you're asking if "process memory" is equal to "virtual memory" or if "process address space" is equal to "virtual address space".

Second: Virtual memory is the only memory which you can use in user mode. You can't access physical memory. Physical memory is for kernel mode and drivers. User mode applications work only with virtual memory. Thus, all memory is virtual in user mode. No need to append "virtual". It's by default.

Therefore, "Process Address Space" = "[Virtual] Process Address Space" - i.e. the virtual address space of the single process. The same goes for "memory": "Process Memory" = "[Virtual] Process Memory".

Third: Now, the "Virtual Memory" term usually refer to "System Virtual Memory" (global thing), which is larger than just one process. On the other hand: since addressing is specific to the process there is no such thing as "System Virtual Address Space" (global address space of all processes and kernel).

So, the answer is:

  1. "Process Address Space" = "Virtual Address Space" = "Address Space"
  2. "Process Memory" <> "Virtual Memory"

Examples

For example, the typical limit for process address space is 4 Gb (for 32-bit apps). However, a typical limit of process virtual memory is 2 Gb (which can be expanded up to 3 Gb for 32-bit machines or 4 Gb for 64-bit machines).

On the other hand, the virtual memory is larger than just your process. Consider the case when you allocate memory through CreateFileMapping function. You can create, say, 64 Gb virtual memory block. That's OK even though 64 Gb > 2 Gb. Of course, you can't use all 64 Gb at the same time (because process address space is just 4 Gb), but you can do it in chunks, say, per 512 Mb.

Also, consider the case when you map the same virtual memory block to mupliple locations (multiple addresses).

In other words, one-to-one mapping between virtual memory and virtual address doesn't exist.

like image 98
Alex Avatar answered Sep 21 '22 12:09

Alex