Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Mar 2006 06:42:42 +0000
From:      Norbert Koch <nkoch@demig.de>
To:        Daniel Rudy <dr2867@pacbell.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: What is the proper use of mlock(2)/munlock(2)?
Message-ID:  <442A2C62.4030003@demig.de>
In-Reply-To: <442A2918.9050804@pacbell.net>
References:  <442A2918.9050804@pacbell.net>

next in thread | previous in thread | raw e-mail | index | archive | help


Daniel Rudy schrieb:
> Hello FreeBSD Hackers,
> 
> I've been reading the man page on mlock(2) and a number of questions
> have arisen about it's use.  I have looked at malloc and mmap, and I
> have not been able to figure this one out.  There doesn't seem to be any
> compiler or library options dealing with this either.
> 
> 1) How do you make sure that an allocated address range has been aligned
> on a multiple of the page size given FreeBSD's virtual address map?

Memory allocated by calling mmap(2) is always page aligned. And its
size is always rounded up to a multiple of getpagesize(3).

 From mmap(2):

The mmap() function causes the **pages** starting at addr and continuing
for at most len bytes to be mapped from the object described by fd,
starting at byte offset offset. If len is not a multiple of the
pagesize, the mapped region **may extend past** the specified range.
Any such extension beyond the end of the mapped object will be
zero-filled.


Norbert



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?442A2C62.4030003>