开发者

Which location address in a pointer refers to

What does the address in a pointer refer to, real address location in main memory or virtual address. Can it be configured.

And if it refers to virtual address , does Memory manager needs to convert this address to real address everyt开发者_JS百科ime it is accessed


This depends on your system and OS.

For a typical windows/linux user space application, the address is a virtual memory address. User space applications have no way of accessing the memory using physical addresses - that's one of the abstractions the OS gives each process.

The MMU(Memory management unit) does this translation for every memory access, and it's up to the OS to set up the corect mapping for your process.


If your system uses VM, then the address is virtual, if it doesn't, it isn't. This has nothing to do with either C or C++.


In other words, as a developer/programmer, you don't have to worry about whether the address is virtual or real. Pointer works perfectly in all the cases.


In some OS you are interacting with actual physical addresses e.g. in the old MS-DOS/Apple ][ OS you could poke around directly in the actual graphics memory. However this had the limitation that your program was stuck in a certain place in memory. A bit simplified modern OS have a memory manager that typically shields the application from the actual physical memory, this enables the OS to handle multiple processes in a more effective way and allowing apps virtual memory.


On a real operating system with virtual memory, of course it can't be configured, because normal processes don't have permission to peek and poke at physical memory; they only see virtual memory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜