From: Philippe Anel <xigh@free.fr>
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 18:50:36 +0100 [thread overview]
Message-ID: <4730A96C.7050601@free.fr> (raw)
In-Reply-To: <4730A5CD.6050607@free.fr>
You also can do this in windows :
#include <windows.h>
#include <stdio.h>
void sysfatal(char * reason)
{
printf("'%s' failed with error %d\n", reason, GetLastError());
ExitProcess(0);
}
PUCHAR Page;
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep)
{
if (code == EXCEPTION_ACCESS_VIOLATION) {
if(ep->ExceptionRecord->ExceptionInformation[1] == (DWORD_PTR)
Page){
Page = VirtualAlloc(Page, 4096, MEM_COMMIT, PAGE_READWRITE);
if(Page == 0)
sysfatal("VirtualAlloc: commit");
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_EXECUTE_HANDLER;
}
return EXCEPTION_CONTINUE_SEARCH;
}
int main(int argc, char ** argv)
{
// Reserve
Page = VirtualAlloc(0, 4096, MEM_RESERVE, PAGE_READWRITE);
if(Page == 0)
sysfatal("VirtualAlloc: reserve");
__try{
// Touch
*Page = 0;
puts("touched.");
}
__except(filter(GetExceptionCode(), GetExceptionInformation()))
{
puts("in except");
}
return 0;
}
Philippe Anel a écrit :
> l4 (http://en.wikipedia.org/wiki/L4_microkernel_family) has such api
> ... but it is only a kernel.
>
> Paul Lalonde a écrit :
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> I have an application I'm building which requires OS support to allow
>> a user-space function to fill a page on page-faults. Ideally, I
>> could reserve a chunk of address space but not back it with memory,
>> and then on fault my handler would serve out data from some small
>> cache of user-managed physical pages.
>>
>> My google-fu has been weak in finding such a system-level API in any
>> OS. Has this got a name I should be searching on? I can't believe
>> no-one has implemented user-level page replacement.
>>
>> Thanks,
>> Paul
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.3 (Darwin)
>>
>> iD8DBQFHMKM4pJeHo/Fbu1wRAgezAKCSDVI812jisKkliXjpsWTMU3AlogCcDkOl
>> liIiMj9Y/2xwHx1iFKjSZ8w=
>> =CAPO
>> -----END PGP SIGNATURE-----
>>
>>
>
>
>
next prev parent reply other threads:[~2007-11-06 17:50 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 [this message]
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
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=4730A96C.7050601@free.fr \
--to=xigh@free.fr \
--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).