Why does munmap needs a length as parameter?

daisy picture daisy · Aug 22, 2012 · Viewed 7k times · Source

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.

Answer

user405725 picture user405725 · Aug 22, 2012

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.