Hi,
SoulofDeity wrote:
That's an interesting idea... Have you also thought of a way for the kernel to notify the process that the page has been taken? And what does the program do when that happens?
If the page is truly unused; then the kernel can use "allocate on write" - essentially, map a single physical page full of zeros everywhere as "read only", and then allocate a new page (in the page fault handler) if/when something writes to the page.
Of course for pages that are technically "in use" it won't work. For example, if a process is caching something, or has a scroll-back buffer, or keeps data around so the user can "undo", or has some sort of "lazy" code, or does pre-fetching of anything, etc. In these cases the process has to be notified.
You'd also want some sort of "global page priority" scheme. Is the page that a JVM stopped using 1 ms ago (but will probably want again in 2 ms) more or less important than the user's ability to press "back" on their web browser, or the RAM consumed by the file "foo/bar.txt" in the VFS cache, or that lookup table you generated to speed up CRC32 (which could be re-generated if you need it again), or....
This is all simple enough (e.g. you could just send message/s out to whoever wanted them saying "free all pages below priority X" and let them sort it out themselves). However; it's at this point you realise that if you want to do anything right you need to forget POSIX ever existed.
Cheers,
Brendan