Page 1 of 1

Mr Nice Guy auto allocation

Posted: Fri Aug 10, 2007 5:11 pm
by Gizmo
In most operating systems that implement memory management, if you attempt to access memory at a location you haven't asked the os to set aside for you (allocate) you get some kind of fatal error.

My proposal is a system where accessing pages that haven't had the present bit set will automatically allocate a page inside of the page fault handler routine. But unlike pages that are allocated the politcally correct way (malloc for example) pages that are allocated to cover the mistakes of a ill designed userland program have a 2 bit timer in intervals of seconds so that after 3 seconds the page is set not present and ready to be used again. If a process gets memory leak happy and references way too many pointers that point to pages not allocated yet it will be terminated and the option to disable automatic allocating will be there for debugging.

Maybe if the default way for allocating pages was automatic (the application simply uses an address not allocated yet and the page is allocated) instead of having to make system calls it would be a possible performance gain or at least a simplified way to grant pages to programs.

Posted: Fri Aug 10, 2007 5:59 pm
by Aali
Most modern OS's already allocate pages on-demand within certain areas.

As for the other idea for reducing fatal errors, DONT. No really, i mean it, don't do that. If something goes wrong you want the system to detect it as soon as possible and end the program to avoid possible data corruption.

This could only promote even sloppier programming practices and 'hide' bugs that would have been obvious otherwise. Not to mention the potential for a program to accidentally wipe all your files just because the OS didn't end it in time.