Can a 32-bit processor really address 2^32 memory locations?

前端 未结 4 1785
抹茶落季
抹茶落季 2021-01-12 03:29

I feel this might be a weird/stupid question, but here goes...

In the question Is NULL in C required/defined to be zero?, it has been established that the NULL

4条回答
  •  时光取名叫无心
    2021-01-12 03:54

    It depends upon the operating system. It is related to virtual memory and address spaces

    In practice (at least on Linux x86 32 bits), addresses are byte "numbers"s, but most are for 4-bytes words so are often multiple of 4.

    And more importantly, as seen from a Linux application, only at most 3Gbytes out of 4Gbytes is visible. a whole gigabyte of address space (including the first and last pages, near the null pointer) is unmapped. In practice the process see much less of that. See its /proc/self/maps pseudo-file (e.g. run cat /proc/self/maps to see the address map of the cat command on Linux).

提交回复
热议问题