4 ms·
You can have several virtual addresses mapped to the same physical address. However, if you use bits that are not 1:1 mapped between those two to index into you
by marcan_42 7y ago
You can have several virtual addresses mapped to the same physical address. However, if you use bits that are not 1:1 mapped between those two to index into your cache, then you might end up with one virtual address getting cached in one place in L1, and the other getting cached in another place in L1. That would be bad, because you'd have two potentially inconsistent caches of the same memory.
- MrBuddyCasino 7y ago> You can have several virtual addresses mapped to the same physical address. Ah yes, of course. Is this something that actually happens (e.g. because of processes sharing memory, OS hands out different virtual addresses pointing to the same physical memory) or theoretical in nature?
- Tuna-Fish 7y agoIt does happen, and not just for two different processes. For example, a common trick to implement an efficient circular list for objects of varying size is to map the same physical addresses twice in adjacent locations. Then you can just use a pointer to the start of each object and have no special handling for the case where an object straddles the end of the allocated area.