[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Virtual memory and MiNT
>On Thu, 23 Jun 1994, Pereira Martins wrote:
>
>> Yes, of course. But I'm not the one to do this, because I don't know
>> how virtual memory driver works :-(
>> Sorry.
>
>Well, I'm looking in to it right now, and we'll see how it comes out...
>
>My way of doing it is to let the kernel allocate say, 3MB of buffer, then
>map the first 3 megabytes of TT-ram into this buffer. Then, the bus-error
>handler has to handle the swapping of the other memory.
>
>Now, I wonder if anybody can expain to me the existance of the MMAP swap
>in mem.c. The way I do it the alt memory map is actually the swap memory
>map. Is there another good way of doing this?
Another way, the way that BSD style Unix's do it is what's known as demand
paging.
When a program is started the space for it is allocated in the swap
partition/file, the memory manager's tables are set up so that all the pages
of memory are set to be owned by the process but not allocated. The
program's then started, immediately causing a page fault as the text page
isn't currently in memory. From then on pages are only loaded into main
memory when they are accessed. When all the physical memory has been used up
by pages which have been loaded in pages have to be written out to disk
before the memory page (usually 8K bytes in size) can be reused by the new
page of memory. Paging out algorithms are tricky to get right for optimum
speed efficiency.
Usually the stack pointer for a process is placed right at the top of the
virtual memory map and the text etc. placed near the bottom, the stack can
then grow dynamically downward without hitting the code.
All processes start with at the same virtual base address so sharing text is
incredibly easy to do, you merely map the text pages into the same address
range for all processes. This also makes a true fork() easy as you merely
clone the memory manager tables except that you mark all the pages to be
copied upon the first write access (ie. make them read-only but mark them
(in one of the translation table's unused bytes) so that when you get an
access violation the original contents are cloned into a new page) and clone
the stack pages, both processes, the parent and child, can now be run
without problems.
>--
>Elias M}rtenson ! No joke here.
>elias@proxxi.uf.se ! Sorry for the inconvenience.
>C-programmerare och GNU-fanatiker !
Steve
--
---------------------------------------------------------------------------
Computer Systems Administrator, Dept. of Earth Sciences, Oxford University.
E-Mail: steve@uk.ac.ox.earth (JANET) steve@earth.ox.ac.uk (Internet).
Tel:- Oxford (0865) 282110 (UK) or +44 865 282110 (International).