Thread: Physical and Logical Memory.

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    36

    Physical and Logical Memory.

    I do understand that logical address space/memory is generated by the CPU for the program and physical memory is the one on-to which the logical address space is mapped and which is on the physical memory. Plus, physical memory is not directly accessible to the user.

    Now, my question is (I don't know whether this makes sense or not):

    1- How is the logical address space generated by the CPU? And is this randomly generated?

    2- Why do we need a "relocation register" to map it on the physical memory? Why can't it be directly mapped on the physical memory?

    Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Location
    Croatia
    Posts
    36
    1. Depends on the architecture.
    X86 family of processors use combination of segmentation and paging, although most operating systems today don't really use the "advantages" of segmentation.
    For example, Linux use only 5 segments (kernel code and data, user code and data plus one dummy segment), each 4 gigs large and overlap.

    So in x86 arch. logical address is actually called far pointer consisting of segment selector(16 bit) and offset(32bit).
    You can choose segments through one of the segment registers: CS, DS, SS, ES, GS and FS. Through them, in protected mode, you actually give an index to GDT(Global description table) where information about each segment are stored (start address, size, premissions....).
    After it goes "through" the GDT to pickup it's base address, an offset is added to form a linear address. Then, that linear address is translated through the paging mechanism to form a physical address.
    *Also note, when you say physical address, it is an array of bits that will be presented on processor's pins which are connected to address bus. They don't have to necessarily address a system memory(RAM).

    In operating system environment all that mechanism is well hidden from you.
    Operating system allocates a huge block of logical address space for a process...say 4GB...and that addr. space is divided in pages, each fixed size(4kB on x86). Then memory manager (part of the OS kernel) translates only allocated pages to physical address.
    So logical address is "not" generated by the CPU, but software, operating system.


    2. Not really sure what "relocation register" is...

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    1
    The relocation register is used by the MMU to map logical addresses to physical addresses. The relocation register has a base physical memory address which is added to the base logical address of the process, that is it maps the logical address to a physical address. The reason for this is that you don't want the process to know their true memory addresses, this could pose a security risk to other processes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2 questions concerning memory
    By Masterx in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-12-2009, 12:08 PM
  2. The inner-workings of a uP
    By Cell in forum Tech Board
    Replies: 26
    Last Post: 02-23-2009, 01:54 PM
  3. logical and physical device access
    By pastitprogram in forum Windows Programming
    Replies: 9
    Last Post: 08-05-2008, 03:46 PM
  4. physical address or logical ??
    By agarwaga in forum C++ Programming
    Replies: 1
    Last Post: 02-25-2006, 02:36 PM
  5. Size of 1 pixel
    By ooosawaddee3 in forum C++ Programming
    Replies: 4
    Last Post: 07-26-2002, 08:06 PM