-   Linux - Software (
-   -   The address mapping from Virtual to Physical memory (

nhua 04-20-2015 02:01 PM

The address mapping from Virtual to Physical memory
I used valloc in user mode to get the memory. The valloc address returned is 0. Does Linux user mode have API can get this physical address? For testing and debugging purpose, I need to know where the virtual address 0 is mapped into physical memory.

smallpond 04-20-2015 04:16 PM

valloc allocates virtual memory. There may not be any physical memory assigned until you attempt to use it and cause a page fault (lazy allocation), so there may not be any mapping. In any case, the mapping can change at any time depending on the demands on physical memory.

nhua 04-20-2015 04:47 PM

The return address value of valloc
I am trying to evaluate the performance of Intel E5, so I called fork{} to generate child process, then inside child process, valloc and mlock to allocate memory for each CPU's thread, but what I got all of 20 thread's virtual memory addresses from the return of valloc were 0. They sounded incorrectly, didn't they?

johnsfine 04-20-2015 04:51 PM

0 is not a correct virtual address. 0 is a reserved virtual address. As a return from valloc, 0 means the request failed.

It is correct that each fork would tend to return the same virtual address. That represents different memory, because each process has its own mapping of virtual to physical. But 0 is not correct.

All times are GMT -5. The time now is 10:17 PM.