Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:45:42+00:00 2026-06-16T01:45:42+00:00

Any suggestions/discussions are welcome! The question is actually brief as title, but I’ll explain

  • 0

Any suggestions/discussions are welcome!

The question is actually brief as title, but I’ll explain why I need physical address.


Background:

These days I’m fascinated by cache and multi-core architecture, and now I’m quite curious how cache influence our programs, under the parallel environment.

In some CPU models (for example, my Intel Core Duo T5800), the L2 cache is shared among cores. So, if program A is accessing memory at physical address like

0x00000000, 0x20000000, 0x40000000...

and program B accessing data at

0x10000000, 0x30000000, 0x50000000...

Since these addresses share the same suffix, the related set in L2 cache will be flushed frequently. And we’re expected to see two programs fighting with each other, reading data slowly from memory instead of cache, although, they are separated in different cores.

Then I want to verify the result in practice. In this experiment, I have to know the physical address instead of virtual address. But how can I cope with this?


The first attempt:

Eat a large space from heap, mask, and get the certain address.

My CPU has a L2 cache with size=2048KB and associativity=8, so physical addressess like 0x12340000, 0x12380000, 0x123c0000 will be related to the first set in L2 cache.

int HEAP[200000000]={0};
int *v[2];
int main(int argc, char **argv) {

    v[0] = (int*)(((unsigned)(HEAP)+0x3fffc) & 0xfffc0000);
    v[1] = (int*) ((unsigned)(v[0]) + 0x40000); 

    // one program pollute v[0], another polluting v[1]
}

Sadly, with the “help” of virtual memory, variable HEAP is not always continuous inside physical memory. v[0] and v[1] might be related to different cache sets.


The second attempt

access /proc/self/mem, and try to get memory information.

Hmm… seems that the results are still about virtual memory.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:45:44+00:00Added an answer on June 16, 2026 at 1:45 am

    Your understanding of memory and these addresses is incomplete/incorrect. Essentially, what you’re trying to test is futile.

    In the context of user-mode processes, pretty much every single address you see is a virtual address. That is, an address that makes sense only in the context of that process. The OS manages the mapping of where this virtual memory space (unique to a process) maps to memory pages. These memory pages at any given time may map to pages that are paged-in (i.e. reside in physical RAM) – or they may be paged-out, and exist only in the swap file on disk.

    So to address the Background example, those addresses are from two different processes – it means absolutely nothing to try and compare them. Whether or not their code is present in any of the caches depends on a number of things, including the cache-replacement strategy of the processor, the caching policies enabled by the OS, the number of other processes (including kernel-mode threads), etc.

    In your first attempt, again you aren’t going to get anywhere as far as actually testing CPU cache directly. First of all, your large buffer is not going to be on the heap. It is going to be part of the data section (specifically the .bss) of the executable. The heap is used for the malloc() family of memory allocations. Secondly, it doesn’t really matter if you allocate some huge 1GB region, because although it is contiguous in the virtual address space of your process, it is up to the OS to allocate pages of virtual memory wherever it deems fit – which may not actually be contiguous. Again, you have pretty much no control over memory allocation from userspace. “Is there a way to allocate contiguous physical memory from userspace in linux?” The short answer is No.

    /proc/$pid/maps isn’t going to get you anywhere either. Yes there are plenty of addresses listed in there, but again, they are all in the virtual address space of process $pid. Some more information on these: How do I read from /proc/$pid/mem under Linux?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry about the extremely vague question title (any suggestions for improvements welcome) I have
Any suggestions on why a VB6 program would be slower when compiled than when
any suggestions for a C# object pooling framework? requirements are multi-thread support and a
Any suggestions on how I can cleanup the following code pattern that repeats multiple
Any suggestions on whether fewer check constraints are better, or more? How should they
Any suggestions on the best way to display this table on an Android platform?
Any suggestions on the best logic to create a new variable in a r
Anyone have any suggestions on how to make randomized colors that are all greenish?
Does anyone have any suggestions on how to edit an <a href=''> link in
Does anyone have any suggestions about where I can find a C# implementation for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.