pointers size with respect to RAM, architecture

一个人想着一个人 提交于 2020-01-25 10:28:27

问题


there were many questions what determines size of a pointer. basically as a rule of thumb you can say this is processor architecture,

x86 -> 4 bytes pointer

x64 -> 8 bytes pointer

I have seen also that some people here say it is system bus that is responsible for it, but other denied. Let's say architecture tells me what is the size of a pointer.

To address 4GB of RAM you need 4,294,967,296 mappings and pointer of size 4 bytes can address 4,294,967,296 memory locations.

To address 8GB of RAM you need 8,589,934,592 mappings and pointer of size 4 bytes cannot address all possible values. so this is why I cannot have more than 4GB RAM on x86 architecture?


回答1:


Amount of RAM is not limited by the architecture (32 or 64 bit). Architecture only decides how much memory can be addressed at a time, by the OS and the programs running on it. On a 32-bit machine, that is, a machine with 32-bit wide memory bus, the OS and the programs can "see" only 4 GB of memory. But that doesn't mean there is only 4 GB of RAM. If the manufacturer has provided for it, you can have 16 GB or 4x4 GB of RAM. In that case, there will be 2 more "hidden" address lines and also there'd be hardcoded logic to decide the levels of those 2 lines, thus selecting any of the available 4 GB RAMs - 00 01 10 11 . These "hidden" address bits are not used by the software layers, so for these layers, they can only use a 4-byte pointer. The number of these "hidden" address lines decides by how much you can extend your RAM.

This is just one example. It depends on the vendor, how they decide to provide for the extra RAM.



来源:https://stackoverflow.com/questions/15344505/pointers-size-with-respect-to-ram-architecture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!