3

I was wondering what differences and relations are between logical and virtual memory? How do their purposes differ?

Are the relations and differences the same for logical and virtual addresses?

3
  • Tell us your frame of reference, first. There is not a single nomenclature for this. In the x86 world, for example, there are (in Intel's nomenclature) logical, linear, and physical addresses. Whose nomenclature are you using, and for what processor architecture? Without that context, your question is meaningless.
    – JdeBP
    Aug 4, 2011 at 18:16
  • @JdeBP: I am considering to understand at a level that is independent of particular OS and architecture. The context would be like when a student is studying OS and architecture courses, using particular OSes and architectures as examples instead of dedication to them.
    – Tim
    Aug 4, 2011 at 18:37
  • Then your question is meaningless, because these things are not independent of architecture.
    – JdeBP
    Aug 4, 2011 at 19:06

2 Answers 2

6

Let's go over the difference between virtual and logical addressing first. I believe the distinction is that "logical address" means that the address the program sees is different from the physical address of the data being stored in RAM.

If you have virtual memory, there may be no physical address at all, as the data stored could be swapped out to disk. However, it is possible to have a system without virtual memory where logical addresses are different from physical addresses, but each logical address is mapped to a physical address. This would make it easier to run multiple programs without them stepping on each other, but wouldn't let the programs use more memory than the physical memory available to the system.

So there is no separate "logical memory" in a computer, though I suppose you could say that a computer with logical addresses but no virtual memory system has a logical memory system. I would just say that logical memory is memory addressed via some indirection method. Is there some specific computer system that you have in mind?

--

Taking your comments into account:

Logical addresses for the same physical memory can be the same or different. Usually two processes won't have access to the same memory, since then one can corrupt the other. However, if they have arranged to use some form of shared memory, they will usually map that shared memory to different addresses. Virtual addresses are more or less a type of logical address, so if you have an operating system that supports VM, and two processes map shared memory, they will usually see that memory as being at different addresses, the same as if there was no virtual memory.

As for your understanding of the purpose of logical vs virtual, virtual memory is for using the HD to extend the memory that you have available to programs. Logical addressing can be used for more than process separation, but that would be one major use.

3
  • Not particular architecture, although X86 and X86-64 are all I can use.Thanks! (1) I wonder if logical addresses are from the point of view of a process? From different processes, are their logical addresses for the same physical address the same or different? On the contrary, virtual addresses for the same physical address are the same, regardless of which process views this? (2) Are logical memory/addresses for the purpose of separate the memory used by different processes, ie memory protection, while virtual memory are for using hard disk as if they were main memory?
    – Tim
    Aug 4, 2011 at 14:12
  • Logical addressing is from the processes perspective. So two processes sharing the same physical address may or may not have the same logical address. Virtual address == logical address. So they may or may not be the same. Note we have not mentioned the memory page table. (2) For all purposes, Virtual memory == logical memory. The virtual memory on the harddrive you are referring to is called a page file. Pages of information in physical memory is written to the page file when they aren't being used to make room for pages of information that are being used.
    – surfasb
    Aug 5, 2011 at 5:25
  • So each x86 process has 4GB of virutal/logical memory available to it, even though there is only, say, 2GB of physical memory available to it.
    – surfasb
    Aug 5, 2011 at 5:27
3

"Logical" memory addresses are used by a process to reference its code and data. Translation from a logical address to a physical address depends on the memory model.

When memory is directly mapped (i.e. real mode), the logical memory address is identical to the physical memory address.

If physical memory is larger than the processor's address space (such as on a 16-bit processor), then memory bank hardware is often employed to expand the usable amount of physical memory. Intel 8086/8088 processors used flexible segment registers instead of a fixed bank scheme. Translation of a (16-bit) logical address to a (20-bit) physical address would use the bank map tables. For x86 the logical address would probably include specification of a segment register.

If the physical address range is larger than the typical physical memory (such as 32-bit processors a decade ago), then virtual memory hardware is employed to provide use of the full address range. The logical addresses are backed by physical memory on demand. To accommodate the full virtual/logical address space and/or to provide each process with its own address space, a backing store is needed to hold swapped out copies of virtual memory. The swapped memory could be organized by segments or pages or segmented pages.

BTW in my years of Unix kernel hacking, I rarely heard or used the phrase "logical (memory) address". If you weren't referring to the physical memory address, then it was the virtual address. That is, "logical address" == "virtual address" (when virtual memory is activated in the MMU).

You must log in to answer this question.

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