Determine whether memory location is in CPU cache

前端 未结 3 663
南方客
南方客 2021-02-15 12:33

It is possible for an operating system to determine whether a page of memory is in DRAM or in swap; for example, simply try to access it and if a page fault occurs, it wasn\'t.<

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-15 13:05

    If you try to determine this yourself then the very act of running your program could invalidate the relevant cache lines, hence rendering your measurements useless.

    This is one of those cases that mirrors the scientific principle that you cannot measure something without affecting that which you are measuring.

提交回复
热议问题