[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] mmap

From: John Cowan
Subject: Re: [Chicken-hackers] mmap
Date: Fri, 11 Jul 2014 09:00:46 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

Felix Winkelmann scripsit:

> Since nobody replied to this - I wouldn't know how this is done.  I
> guess there is some UNIX arcana that allows one to implement
> non-blocking behaviour. As memory access will cause the blocking, we
> can probably not check for this via poll/select. Do you have any
> information about this? Is it possible to test whether a page is in
> memory, and whether one can do the equivalent of a poll/select on
> this?

There is no way to do this.  By messing around with Linux-specific
mmap() flags, you can get Linux to prepage the whole file, paying the
entire cost at once, but short of that (and it is not portable at all),
you have no way of knowing when the mapped pages are in; after all,
even if paged in they could be pushed out at any moment.

One trick I've heard of is to spawn a child process which calls mlock()
to lock the pages down and writes locked addresses to a pipe as it goes.
The parent can then read that pipe with select() or poll().  After the job
is done, the child goes to sleep() forever, but the parent must be sure
to kill it before exiting.

John Cowan        address@hidden
The first thing you learn in a lawin' family is that there ain't
no definite answers to anything.  --Calpurnia in To Kill A Mockingbird

reply via email to

[Prev in Thread] Current Thread [Next in Thread]