From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4730A96C.7050601@free.fr> Date: Tue, 6 Nov 2007 18:50:36 +0100 From: Philippe Anel User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] Memory management questions/not plan-9 specific References: <11F071B3-1B01-4272-9EA4-1C2BD50BCC0B@telus.net> <4730A5CD.6050607@free.fr> In-Reply-To: <4730A5CD.6050607@free.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: eb85a518-ead2-11e9-9d60-3106f5b1d025 You also can do this in windows : #include #include 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 =3D=3D EXCEPTION_ACCESS_VIOLATION) { if(ep->ExceptionRecord->ExceptionInformation[1] =3D=3D (DWORD_PTR= )=20 Page){ Page =3D VirtualAlloc(Page, 4096, MEM_COMMIT, PAGE_READWRITE)= ; if(Page =3D=3D 0) sysfatal("VirtualAlloc: commit"); return EXCEPTION_CONTINUE_EXECUTION; } return EXCEPTION_EXECUTE_HANDLER; } return EXCEPTION_CONTINUE_SEARCH; } int main(int argc, char ** argv) { // Reserve Page =3D VirtualAlloc(0, 4096, MEM_RESERVE, PAGE_READWRITE); if(Page =3D=3D 0) sysfatal("VirtualAlloc: reserve"); __try{ // Touch *Page =3D 0; puts("touched."); } __except(filter(GetExceptionCode(), GetExceptionInformation())) { puts("in except"); } return 0; } Philippe Anel a =E9crit : > l4 (http://en.wikipedia.org/wiki/L4_microkernel_family) has such api=20 > ... but it is only a kernel. > > Paul Lalonde a =E9crit : >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> I have an application I'm building which requires OS support to allow=20 >> a user-space function to fill a page on page-faults. Ideally, I=20 >> could reserve a chunk of address space but not back it with memory,=20 >> and then on fault my handler would serve out data from some small=20 >> cache of user-managed physical pages. >> >> My google-fu has been weak in finding such a system-level API in any=20 >> OS. Has this got a name I should be searching on? I can't believe=20 >> no-one has implemented user-level page replacement. >> >> Thanks, >> Paul >> >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.3 (Darwin) >> >> iD8DBQFHMKM4pJeHo/Fbu1wRAgezAKCSDVI812jisKkliXjpsWTMU3AlogCcDkOl >> liIiMj9Y/2xwHx1iFKjSZ8w=3D >> =3DCAPO >> -----END PGP SIGNATURE----- >> >> > > >