From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <13426df10711061028g73f7f4bdy22b4fe882087573@mail.gmail.com> Date: Tue, 6 Nov 2007 10:28:53 -0800 From: "ron minnich" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] Memory management questions/not plan-9 specific In-Reply-To: <4730BBBF.5060202@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <11F071B3-1B01-4272-9EA4-1C2BD50BCC0B@telus.net> <4730B27F.7030608@gmail.com> <4730BBBF.5060202@gmail.com> Topicbox-Message-UUID: ebb87628-ead2-11e9-9d60-3106f5b1d025 On 11/6/07, Robert William Fuller wrote: > Paul Lalonde wrote: > > > > On Nov 6, 2007, at 10:29 AM, Robert William Fuller wrote: > >>> In UNIX, set up a signal handler for SIGSEGV. > > > > Not quite enough - I still need to reserve some address space. mmap > > doesn't let me reserve it without backing it. > > It does by default on Linux :-) > mmap /dev/zero over the region you want. Or not, you can just any piece of your address space, actually. mprotect it (page-aligned, now!0 so you can't access it. record the fact that you did this. i.e. set up data structures that allow you to tell, in the segv handler, that it's a "page fault" and not a true screwup in your code. in the segv handler, get the fault address and type, search your structs, figure out what to do. Be sure to compute page frame from the address, etc. etc. fix it up with memprotect. record what you did. return. that's pretty much what I did. ron