9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "ron minnich" <rminnich@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] Memory management questions/not plan-9 specific
Date: Tue,  6 Nov 2007 10:28:53 -0800	[thread overview]
Message-ID: <13426df10711061028g73f7f4bdy22b4fe882087573@mail.gmail.com> (raw)
In-Reply-To: <4730BBBF.5060202@gmail.com>

On 11/6/07, Robert William Fuller <hydrologiccycle@gmail.com> 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


  reply	other threads:[~2007-11-06 18:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-06 17:24 Paul Lalonde
2007-11-06 17:35 ` Philippe Anel
2007-11-06 17:50   ` Philippe Anel
2007-11-06 17:51 ` ron minnich
2007-11-06 18:29 ` Robert William Fuller
2007-11-06 17:47   ` Paul Lalonde
2007-11-06 19:08     ` Robert William Fuller
2007-11-06 18:28       ` ron minnich [this message]
2007-11-06 20:12         ` Paul Lalonde
2007-11-09  9:30 ` Dave Eckhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13426df10711061028g73f7f4bdy22b4fe882087573@mail.gmail.com \
    --to=rminnich@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).