加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

用户进程的有效地址空间是什么? (OS X和Linux)

发布时间:2020-12-14 00:33:50 所属栏目:Linux 来源:网络整理
导读:mmap系统调用文档说如果以下情况该函数将失败: MAP_FIXED was specified and the addr argument was not page aligned,or part of the desired address space resides out of the valid address space for a user process. 我无法在任何地方找到文档来说明
mmap系统调用文档说如果以下情况该函数将失败:

MAP_FIXED was specified and the addr
argument was not page aligned,or part
of the desired address space resides
out of the valid address space for a
user process.

我无法在任何地方找到文档来说明要映射的有效地址. (我有兴趣在OS X和Linux上执行此操作,理想情况下,相同的地址对两者都有效…).

解决方法

Linux内核为用户空间(几乎)无法访问且无法映射任何内容的部分虚拟地址空间保留.您正在寻找所谓的“userspace / kernelspace split”.

在i386上,arch默认为3G / 1G one – 用户空间低3 GB的虚拟地址空间,内核高1 GB,另外还有2G / 2G和1G / 3G分割:

config PAGE_OFFSET
        hex
        default 0xB0000000 if VMSPLIT_3G_OPT
        default 0x80000000 if VMSPLIT_2G
        default 0x78000000 if VMSPLIT_2G_OPT
        default 0x40000000 if VMSPLIT_1G
        default 0xC0000000
        depends on X86_32

在x86_64上,用户空间位于(当前)48位虚拟地址空间的下半部分:

/*
 * User space process size. 47bits minus one guard page.
 */
#define TASK_SIZE_MAX   ((1UL << 47) - PAGE_SIZE)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读