为什么munmap需要长度作为参数? [英] Why does munmap needs a length as parameter?

查看:80
本文介绍了为什么munmap需要长度作为参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,为什么映射内存的大小作为一个参数传入,因为从同一地址开始不能有一个以上的映射(可以吗?),为什么Linux内核不会记录两个起始地址,长度在一起,但是让用户空间程序记住它们.

I was wondering, why should the size of mapped memory being one parameter passed in, since there couldn't more more than one mapping starting from same address (could they ?), why won't linux kernel record both start address, length together, but let userspace program remember them.

我的意思是,为什么不做呢,只需使用起始地址作为主键来存储信息树.

I mean, why wouldn't it be, just use the start address as primary key to store the information tree.

推荐答案

一个可以map,例如5页,后来的unmap其中之一.有关要取消映射的页面的信息将作为地址和长度传递,其中长度是页面大小的倍数.

One can map, say, 5 pages and later unmap one of them. And information about what pages to unmap is passed as address and length where the length is a multiple of page size.

这篇关于为什么munmap需要长度作为参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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