Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: use of hex-number in references

by dave_the_m (Monsignor)
on Jun 09, 2004 at 01:07 UTC ( #362600=note: print w/replies, xml ) Need Help??


in reply to use of hex-number in references

Yes, they correspond to the address of the SV structure which holds the hash or array.

Dave.

Replies are listed 'Best First'.
Re^2: use of hex-number in references
by tachyon (Chancellor) on Jun 09, 2004 at 05:50 UTC

    And you can actually get to them using Devel::Pointer.

    use Devel::Pointer; $a = 'Hello World'; $scalar_ref = \$a; print "Scalar Ref is $scalar_ref\n"; $what = unsmash_sv(0+$scalar_ref); print "$scalar_ref is actually >$what<\n"; __DATA__ Scalar Ref is SCALAR(0x1ab2734) SCALAR(0x1ab2734) is actually >Hello World<

    cheers

    tachyon

Re^2: use of hex-number in references
by arthas (Hermit) on Jun 09, 2004 at 07:46 UTC

    This is probably a silly questions, but my inexperience with memory management forces me to post it. ;-)

    So, those references are actually pointers which map directly to system memory. However, if the systems moves around memory zones (i.e. it puts something on the swap file/partition), how can they remain valid?

    Thanks, Michele.

      The addresses programs use are virtual addresses. These are translated to real (physical) addresses by the OS and/or the CPU transparently to the program.

      The following extract from here says it better.

      Address translation

      This means the virtual addresses generated by a program are different from the physical addresses that go onto the address bus; to the memory chips. The translation of virtual addresses to physical addresses is performed by special hardware inside the CPU called a memory management unit (MMU).

      Address translation can be used for the kernel as well as the tasks. This lets you link the kernel to run at a specific address, but load the kernel anywhere in memory.

      Besides address translation, the MMU usually provides memory protection. Ranges of memory can be made to cause a page fault or general protection fault by any combination of writing to the memory range, accessing the memory range in any way (read, write, execute), access to the memory range by code running at user privilege (ring 3).


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://362600]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2022-09-26 05:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (117 votes). Check out past polls.

    Notices?