是否有任何物理部分的内存地址为NULL(0)? [英] Is there any physical part of memory with the address of NULL(0)?

查看:191
本文介绍了是否有任何物理部分的内存地址为NULL(0)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一个古老的说法,当你想表明这个特定的指针不指向任何应该设置为NULL(实际上是0),但我想知道是不是实际上有一个物理部分的内存NULL的地址(0)?

I know there's an old saying when you want to indicate this specific pointer doesn't point to anything it should be set to NULL(actually 0), but I'm wondering isn't there actually a physical part of memory with the address of NULL(0) ?

推荐答案

总有一个物理地址为0(但它可能不一定映射到物理RAM),但在典型的平台上,任何访问通常将在虚拟地址空间中执行(如jweyrich指出的,可以使用 mmap 等直接映射物理地址空间),所以任何读/写地址0的尝试都会引发某种异常。

There is always a physical address of 0 (but it may not necessarily map onto physical RAM), but on a typical platform any accesses will typically be performed in a virtual address space (as jweyrich points out below, you can use mmap and so on to directly map the physical address space), so any attempt to read/write to address 0 will raise an exception of some kind.

在更简单的处理器(例如微控制器等)可能没有这样的保护,所以如果你尝试写入地址0,就没有什么可以抓住你。

On simpler processors (think microcontrollers and so on), there may be no such protection, so if you attempt to write to address 0, there'll be nothing to catch you.

注意一个空指针不一定必须指向地址0;唯一的保证是它将比较等于整数值 0

Note also that a null pointer doesn't necessarily have to point at address 0; the only guarantee is that it will compare equal to integer value 0.

这篇关于是否有任何物理部分的内存地址为NULL(0)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆