From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 19 14:32:28 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7D4F1065698 for ; Thu, 19 Nov 2009 14:32:28 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outW.internet-mail-service.net (outw.internet-mail-service.net [216.240.47.246]) by mx1.freebsd.org (Postfix) with ESMTP id A8B4C8FC17 for ; Thu, 19 Nov 2009 14:32:28 +0000 (UTC) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id B159814E045; Thu, 19 Nov 2009 06:32:28 -0800 (PST) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by idiom.com (Postfix) with ESMTP id 949E62D6021; Thu, 19 Nov 2009 06:32:27 -0800 (PST) Message-ID: <4B0556FA.1080709@elischer.org> Date: Thu, 19 Nov 2009 06:32:26 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Sharad Chandra References: <200911171529.20098.sharadc@in.niksun.com> <200911181433.52557.jkim@FreeBSD.org> <200911191627.34076.sharadc@in.niksun.com> In-Reply-To: <200911191627.34076.sharadc@in.niksun.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Kostik Belousov , freebsd-hackers@freebsd.org, Robert Watson , Jung-uk Kim , Manprit Singh Subject: Re: mprotect(2) clears the flag for whole page which causes program crash. 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: Thu, 19 Nov 2009 14:32:28 -0000 Sharad Chandra wrote: > ,---- [Jung-uk Kim wrote:] > | On Wednesday 18 November 2009 01:52 pm, Robert Watson wrote: > | > On Tue, 17 Nov 2009, Sharad Chandra wrote: > | > > Is it known bug or is there any workaround? How will a userland > | > > process make sure that process will not crash as malloc(3) can > | > > allocate where ever it get the memory free to use. > | > > | > mprotect(2) operates on pages, so you'll want to use mmap(2) and > | > munmap(2) to allocate and free pages directly rather than > | > mallac(3), which manages byte ranges from pages managed using those > | > same interfaces. > | > | For example: > | > | http://docs.freebsd.org/cgi/mid.cgi?200911181926.nAIJQHOR081471 > | > > Thanks everyone. mmap(2) worked and program did not crash. Only problem with > it I use only fraction of allocated memory (each request alocate minimum of > one page and my request is in hundreds), rest is waste of it so no one else > will get this memory to use. And if a process runs as daemon and makes many > request, It can hold a lot of it. Just a question floated in mind. write your own allocator that efficiently divides up the mmapped pages among several requests? > > Many thanks, > Sharad Chandra > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"