Address stored by pointers is PHYSICAL or LOGICAL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tyagithehacker
    New Member
    • Jul 2010
    • 24

    Address stored by pointers is PHYSICAL or LOGICAL

    Me and 1 of my friend were arguing, over the nature of address stored by pointers in c language.

    He was saying that its logical address, while i thought he is wrong. can anyone plz tell me who is right, he or me, plz give the reasion for the same.

    thanx in advance.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Its platform dependent. I don't know what a "logical" address is but on a platform like Windows where ever program has a virtual address space your pointers will be storing virtual addresses in that address space.

    On a simple embedded platform where the process has direct access to the physical memory then you might well be storing the direct physical address of them memory.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      The logical address is what is stored in a pointer.

      The logical address is determined by a model called the address space. This model may contain more elocations that there is memory in the computer. No matter.

      There is no relationship between the logical address and the physical memory location in the computer.

      The operating system will convert these logical addresses to physical addresses as the program runs.

      Comment

      • tyagithehacker
        New Member
        • Jul 2010
        • 24

        #4
        Originally posted by Banfa
        Its platform dependent. I don't know what a "logical" address is but on a platform like Windows where ever program has a virtual address space your pointers will be storing virtual addresses in that address space.

        On a simple embedded platform where the process has direct access to the physical memory then you might well be storing the direct physical address of them memory.
        can you please tell me what type of plateform "UNIX red hat" is...??

        Comment

        • tyagithehacker
          New Member
          • Jul 2010
          • 24

          #5
          Originally posted by weaknessforcats
          The logical address is what is stored in a pointer.

          The logical address is determined by a model called the address space. This model may contain more elocations that there is memory in the computer. No matter.

          There is no relationship between the logical address and the physical memory location in the computer.

          The operating system will convert these logical addresses to physical addresses as the program runs.
          can you please explain this line of yours..

          "There is no relationship between the logical address and the physical memory location in the computer."

          As i feels that there is a corresponding physical address to each and every logical address.

          Comment

          • donbock
            Recognized Expert Top Contributor
            • Mar 2008
            • 2427

            #6
            I guess I would rephrase weaknessforcat' s statement as
            "There need not be an obvious relationship between the logical address stored in a pointer variable and the corresponding physical memory address in the computer."

            For example, consider an operating system that swaps memory pages to and from the hard drive. Each time a given page swaps in it will typically reside in a different block of physical memory. The logical addresses are still the same, but the corresponding physical addresses have changed. The relationship is dynamic; that is certainly non-obvious.

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Originally posted by tyagithehacker
              can you please tell me what type of plateform "UNIX red hat" is...??
              Like Windows Linux uses a swap drive and a virtual address space/map.


              When weaknessforcats says there is no relationship between the logical address and the physical memory location that is not quite accurate. There is a relationship of some sort but it is controlled by the memory manager and is dynamic so you would have no way of determining what it is.

              So for all intents and purposes from your (or your programs) point of view there is no relationship that you can use. The memory manager in the OS will know what the relationship is.

              Comment

              • tyagithehacker
                New Member
                • Jul 2010
                • 24

                #8
                Originally posted by Banfa
                Like Windows Linux uses a swap drive and a virtual address space/map.


                When weaknessforcats says there is no relationship between the logical address and the physical memory location that is not quite accurate. There is a relationship of some sort but it is controlled by the memory manager and is dynamic so you would have no way of determining what it is.

                So for all intents and purposes from your (or your programs) point of view there is no relationship that you can use. The memory manager in the OS will know what the relationship is.
                As u said before:-

                On a simple embedded platform where the process has direct access to the physical memory then you might well be storing the direct physical address of them memory.

                can u please tell me some/any of the OS/plateforms where processes has direct access to physical memory.

                does it mean that under those OS/plateforms there is no memory manager exist.

                and if there is no virtual space or swap partition present in such OS, then how the swapping (or multiprocessing more technically speaking) is done there.

                ----thanx in advance. :-)

                Comment

                • Banfa
                  Recognized Expert Expert
                  • Feb 2006
                  • 9067

                  #9
                  On many micro-controllers and micro-processors the program will be using direct physical addresses, for example, ARM, PIC, ST20, 68000, such platforms do not have a memory management unit by default.

                  There are many OSs available for these platforms such as ThreadX, uCOS/uCOSII, vxWorks, OpenOS, Nucleus, these tend to be relatively light OSs just providing a threading facility with task synchronisation objects, may be some timing facilities and memory management code. Some, like ThreadX, vxWorks, Nucleus have lots of optional modules for control of various hardware peripherals (USB stack, network etc).


                  On the other hand some micro-controllers, e.g. Cyan eCog1x, have on board memory management units separating logical address from physical address.

                  Virtual memory/swap partitions just provide an extra source of RAM albeit slower. Normally platforms with swap space use it to store the data for programs that are not currently running. However any system whether it has virtual memory or not is limited to using only the memory it has available.

                  Your available memory on a system with virtual memory is (virtual memory size* + physical ram size) on a system without virtual memory you are limited to physical ram size.

                  In either case the OS has to find space for all the memory required for all the processes it is currently running. Although it is not normal for a program to directly access the virtual memory, the OS will swap pages of virtual memory into an out of physical RAM so that the running programs data is in RAM for access.

                  On an embedded platform normally you will only be running 1 process, possibly with multiple threads.




                  *Note windows can dynamically increase the size of its virtual memory size however if you get to that point in my experience you will be suffering serious system degradation because too high a proportion of ram is being served from virtual memory.

                  Comment

                  • tyagithehacker
                    New Member
                    • Jul 2010
                    • 24

                    #10
                    Originally posted by Banfa
                    On many micro-controllers and micro-processors the program will be using direct physical addresses, for example, ARM, PIC, ST20, 68000, such platforms do not have a memory management unit by default.

                    There are many OSs available for these platforms such as ThreadX, uCOS/uCOSII, vxWorks, OpenOS, Nucleus, these tend to be relatively light OSs just providing a threading facility with task synchronisation objects, may be some timing facilities and memory management code. Some, like ThreadX, vxWorks, Nucleus have lots of optional modules for control of various hardware peripherals (USB stack, network etc).


                    On the other hand some micro-controllers, e.g. Cyan eCog1x, have on board memory management units separating logical address from physical address.

                    Virtual memory/swap partitions just provide an extra source of RAM albeit slower. Normally platforms with swap space use it to store the data for programs that are not currently running. However any system whether it has virtual memory or not is limited to using only the memory it has available.

                    Your available memory on a system with virtual memory is (virtual memory size* + physical ram size) on a system without virtual memory you are limited to physical ram size.

                    In either case the OS has to find space for all the memory required for all the processes it is currently running. Although it is not normal for a program to directly access the virtual memory, the OS will swap pages of virtual memory into an out of physical RAM so that the running programs data is in RAM for access.

                    On an embedded platform normally you will only be running 1 process, possibly with multiple threads.




                    *Note windows can dynamically increase the size of its virtual memory size however if you get to that point in my experience you will be suffering serious system degradation because too high a proportion of ram is being served from virtual memory.
                    wow, very nicely answered. thanx :-)

                    Comment

                    Working...