From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 29 06:43:21 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CC44C16A400 for ; Wed, 29 Mar 2006 06:43:21 +0000 (UTC) (envelope-from nkoch@demig.de) Received: from server.absolute-media.de (server.absolute-media.de [213.239.231.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4A2E343D49 for ; Wed, 29 Mar 2006 06:43:20 +0000 (GMT) (envelope-from nkoch@demig.de) Received: from localhost (unknown [127.0.0.1]) by server.absolute-media.de (Postfix) with ESMTP id B8F91BF747; Wed, 29 Mar 2006 08:43:18 +0200 (CEST) Received: from server.absolute-media.de ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 22876-10; Wed, 29 Mar 2006 08:43:13 +0200 (CEST) Received: from firewall.demig (p5083985D.dip0.t-ipconnect.de [80.131.152.93]) by server.absolute-media.de (Postfix) with ESMTP id A6B74A72DE; Wed, 29 Mar 2006 08:43:13 +0200 (CEST) Received: from [192.168.1.72] (ws-ew-3.demig.intra [192.168.1.72]) by firewall.demig (8.13.6/8.13.5) with ESMTP id k2T6fXcj021890; Wed, 29 Mar 2006 08:41:33 +0200 (CEST) (envelope-from nkoch@demig.de) Message-ID: <442A2C62.4030003@demig.de> Date: Wed, 29 Mar 2006 06:42:42 +0000 From: Norbert Koch User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Daniel Rudy References: <442A2918.9050804@pacbell.net> In-Reply-To: <442A2918.9050804@pacbell.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at absolute-media.de Cc: freebsd-hackers@freebsd.org Subject: Re: What is the proper use of mlock(2)/munlock(2)? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2006 06:43:21 -0000 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