[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Any correlation between malloc return value and physical location?



>Is there any relationship between the address returned by malloc(3) and
>the physical address of the block of RAM?

no relation if you have virtual memory mangement (most linux boxes),
this is why it's called virtual.
There may be embedded linux variants without virtual memory mangement.

>If a identical programs (same data, different files) are launched at
>the same time so that each copy in memory is identical, and they all
>call malloc(some_constant), do they all get the same return address
>from malloc() or do they get different answers?

generally, when using virtual memory, all programs have their own adress
space, which means they all start at the same memory adresses for
program, data, stack etc. So identical programs should run in identical
virtual memory addresses.

The memory returned by malloc IMHO should return the same address, but
could be dependant on different (e.g. I/O-)events at runtime.

If you have a very simple program doing no system calls, just a
simple malloc, I think it returns the same address.
I never tried in reality, but...

Why do you want to know?



Reply to: