You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by James G Smith <JG...@TAMU.Edu> on 2002/10/30 21:16:18 UTC

Re: Same $dbh under different pids?

Perrin Harkins <pe...@elem.com> wrote:
>harm wrote:
>
>>On Wed, Oct 30, 2002 at 06:05:51PM +0800, Philippe M. Chiasson wrote:
>>  
>>
>>>For the same reason that running this:
>>>$> perl -e'fork; { $foo = {}; print "$$:$foo\n"}'
>>>1984:HASH(0x804c00c)
>>>1987:HASH(0x804c00c)
>>>
>>>produces this for me, every single time I run this program
>>>
>>>You are assuming that if (0x804c00c) is equal in different processes,
>>>they must be pointers(or references, or handles) to the same thing. And
>>>it is not the case ;-)
>>>
>
>Wait, ins't it the case?  That number is supposed to be the location in 
>memory.  It seems like these are all pointing to the same hash.  I can't 
>explain how that would happen though, based on the code shown here.

The same address in two different applications doesn't always point
to the same place in physical memory.  Virtual memory address !=
physical memory address on most `modern' processors.  This is what
allows copy-on-write to work for Apache children -- all the addresses
are the same, but the data is different.
-- 
James Smith <JG...@TAMU.Edu>, 979-862-3725
Texas A&M CIS Operating Systems Group, Unix