1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

virtual memory

Discussion in 'Engineering Concepts' started by huda, Jan 26, 2009.

  1. huda

    huda New Member

    i would like to know important issue.

    we are knowing that the address field of instruction is virtual address.
    well, if so, how we can estimate the size of RAM by this field?

    ex. if the address field =10 bits
    now we can say , there are 2^10 location in RAM.

    well, if 10 bits are width of virtual not physical address , how by which calculate the number of locations?
    it is supposed the size of RAM be less than 2^10.
    please, resolve this dilemma

    thanks in advance
  2. xpi0t0s

    xpi0t0s Mentor

    You can't deduce the size of RAM from that field alone; you need to know the processor architecture.
    For example x86 used a segment/offset system before the flat 32-bit memory model where near pointers were 16 bits, but you would specify a segment address which was also 16 bit and that could extend you past the 16-bit limitation; a 16:16 scheme is good for up to 4GB. If you know there is no other memory addressing mechanism then you can deduce that the memory cannot be greater than 1K long, but that still doesn't tell you if the memory is shorter.

    I don't understand your virtual/physical question though. 10 bits is just 1K, and you aren't likely to have a virtual memory scheme operating if the processor can only access 1K of RAM. But in any case a 10 bit pointer can only access 1K of memory addresses whether virtual or not.
  3. huda

    huda New Member

    thanks for reply,
    regarding 1k of ram is just example.
    well, i know ,if there are 10 bits the cpu can only acess 1k of memory, but it is very important to know virtual or physical.
    ok, i understand from you , we cant calculate the size of ram just by knowing address field.
    i know, address register has virtual address , what about program counter?
    what is having virtual or physical?
    in other words, is cpu are setting virtual or physical address in startup ?
  4. xpi0t0s

    xpi0t0s Mentor

    Well, assuming the CPU doesn't have an on-board virtual memory manager, it'll only (not just at startup) see physical addresses. Often the VMM is a separate chip from the CPU so that the virtualisation of memory is transparent to the CPU; it just thinks it's addressing 4 straight GB of RAM in a 32-bit chip, and the VMM handles translation to actual memory and page faults etc.

    What CPU are you using?
  5. huda

    huda New Member

    well, I think depending on your clarifying , it is using physical.
    it is meaning , pc is using physical address like address register.
    please, be patient with me if I not on a right reasoning.
    this topic is very important for me, and I would like to tell you that my native language isn't english, so there are two difficult things in front of me . the topic itself and the language.
    just , I ask you to more clarifying about :
    it just thinks it's addressing 4 straight GB of RAM in a 32-bit chip, and the VMM handles translation to actual memory and page faults etc.
    are you meaning 32-bit chip is virtual memory?
    if these registers of cpu has physical address as I understood, what is making cpu thinks addressing 4 gb of ram ? does the address field make cpu thinks that?
  6. xpi0t0s

    xpi0t0s Mentor

    There are lots of different types of CPU with different abilities. Further discussion is relatively pointless without knowing what CPU you are using. I appreciate that it is more difficult for a non-native English speaker to come to terms with tech stuff with the main language being English, but this is not a difficult question: WHAT CPU ARE YOU USING? It's impossible to answer your questions with any accuracy without knowing this.
  7. huda

    huda New Member

    no , it isn't difficult question.
    but I want to clarify my problem.
    when I submitted my inquiry, I didn't talk about a problem regarding my computer,but I talked in general.
    In fact, I'm a new lecturer in architecture stuff at university;I experiencing some problems and inquiries from some students; and I should ready for any enquiry.especially, I will give cache memory soon,so, I should understand all pending matters relate virtual memory. really, I hope to understand.
    I sent three inquiries relate cache ,too. but unfortunately,there is no clear reply yet.
  8. xpi0t0s

    xpi0t0s Mentor

    OK, I understand. Well, in general then, taking the view that the virtual memory manager (VMM) is a separate device from the CPU, *ALL* addresses without exception in the CPU are, from the CPU's viewpoint, physical addresses not virtual. If the CPU requests data from location 0x12345678, then as far as the CPU is concerned, what comes back is at memory location 0x12345678 and that's the end of that.

    Virtual memory then is something that happens separately from the CPU and in effect the CPU knows nothing about it. The VMM takes the CPU's physical address 0x12345678, *reinterprets* that as a virtual address, looks up where that would be in its page table, so let's say it has a page size of 64K then the address of the page would be 0x12340000 and the offset into that page is 0x5678.

    So if the VMM page table links the virtual page at 0x12340000 to actual physical RAM at 0x44440000, then the VMM translates the CPU request for 0x12345678 to a request for 0x44445678 and returns the byte at 0x44445678 to the CPU, without letting it know anything about the change of address.

    So this is the strength of the VMM design. No change in the CPU design is necessary, EXCEPT that it must be able to handle a page fault when it happens. That is where the CPU accesses memory that the VMM knows is not in physical RAM but swapped out to hard disk, and that can take a relatively long time to return the data as it must be loaded in from disk before the relevant value can be returned.

    Relating this to, say, a Windows machine then. In Windows every process operates within its own 4GB address space. What's that? You've got 32 processes, but only 2GB of RAM? Well that's where the VMM steps in. Most of each of those 4GB address spaces will be unused; have a look in Task Manager, Processes tab, enable columns Mem Usage and VM Size, for example my browser (Firefox) has a Mem Usage of 129000K and a VM Size of 115000K, that's a total of 244MB, but I've got 4GB RAM and another 2GB or so swap space, so that's no problem. The VMM will retain lists of process pages and their corresponding addresses in RAM and in swap, so whenever something addresses memory, that will go to the VMM to be translated into a physical address and maybe a page fault will occur.

    Mem Usage is what's in physical RAM, and VM Size is what's on the hard disk in the swap space.

    Enable the column Page Faults in Task Manager and that will show you how many page faults each process has generated. If you're getting loads of page faults, that's a clear indication that you haven't got enough RAM on your system and need to increase it, or do less with the machine. Also have a look at the Performance tab; that shows PF Usage. PF is page file, another word for swap space, which is the disk space used as extra RAM. If that's high that's an indication that your page file is too small and needs extending.

    The VMM is usually a separate chip from the CPU, even in modern PCs. Have a look at the Wiki article http://en.wikipedia.org/wiki/Motherboard and scroll down to the diagram on the right that shows the CPU and two bridges, the Northbridge and Southbridge. The Northbridge is the VMM. So the FSB (front side bus) takes physical addresses from the CPU, which are reinterpreted as virtual addresses by the VMM, and the Memory bus takes physical addresses from the VMM. In that diagram, the CPU knows nothing about virtual memory; it just thinks it's accessing physical memory and the VMM is what implements the virtualisation.
  9. xpi0t0s

    xpi0t0s Mentor

    > I sent three inquiries relate cache ,too. but unfortunately,there is no clear reply yet.

    I think that's because the posts don't make any sense. Can you express more clearly exactly what it is you want to know? Not in this thread though, in one of the others. I'll post a reply to one of them now with some general info.
  10. huda

    huda New Member

    well, I think morris mano when referenced in his book "computer system architecture
    he didn't mean that cpu is referencing to virtual address potentially,because ,by the fact this is what VMM will step .

    this is what was said by morris mano in his book P. 470
    "the address field of the instruction code has a sufficient number of bits to specify all virtual addresses. in our example, the address field of an instruction code will consist of 20 bits but physical memory address must specified with only 15 bits (where the size of memory in that ex. is 2^15).Thus cpu will reference instructions and data with 20 bit but the information at this address must be taken from physical memory "

    thank you very much for the time that was spent for me

Share This Page