what differences and relations are between logical and virtual memory?

25,496

Solution 1

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.

Solution 2

"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).

Share:
25,496

Related videos on Youtube

baz
Author by

baz

Elitists are oppressive, anti-intellectual, ultra-conservative, and cancerous to the society, environment, and humanity. Please help make Stack Exchange a better place. Expose elite supremacy, elitist brutality, and moderation injustice to https://stackoverflow.com/contact (complicit community managers), in comments, to meta, outside Stack Exchange, and by legal actions. Push back and don't let them normalize their behaviors. Changes always happen from the bottom up. Thank you very much! Just a curious self learner. Almost always upvote replies. Thanks for enlightenment! Meanwhile, Corruption and abuses have been rampantly coming from elitists. Supportive comments have been removed and attacks are kept to control the direction of discourse. Outright vicious comments have been removed only to conceal atrocities. Systematic discrimination has been made into policies. Countless users have been harassed, persecuted, and suffocated. Q&A sites are for everyone to learn and grow, not for elitists to indulge abusive oppression, and cover up for each other. https://softwareengineering.stackexchange.com/posts/419086/revisions https://math.meta.stackexchange.com/q/32539/ (https://i.stack.imgur.com/4knYh.png) and https://math.meta.stackexchange.com/q/32548/ (https://i.stack.imgur.com/9gaZ2.png) https://meta.stackexchange.com/posts/353417/timeline (The moderators defended continuous harassment comments showing no reading and understanding of my post) https://cs.stackexchange.com/posts/125651/timeline (a PLT academic had trouble with the books I am reading and disparaged my self learning posts, and a moderator with long abusive history added more insults.) https://stackoverflow.com/posts/61679659/revisions (homework libels) Much more that have happened.

Updated on September 18, 2022

Comments

  • baz
    baz over 1 year

    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?

    • JdeBP
      JdeBP almost 13 years
      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.
    • baz
      baz almost 13 years
      @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.
    • JdeBP
      JdeBP almost 13 years
      Then your question is meaningless, because these things are not independent of architecture.
  • baz
    baz almost 13 years
    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?
  • surfasb
    surfasb almost 13 years
    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
    surfasb almost 13 years
    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.