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

Re: [MiNT] virtual address spaces



Evan Langlois wrote:
The main problem I see is that without an MMU doing shared executables
is really tough since you can't do copy-on-write pages or anything, and
that would be a key benefit to put in place.  You can do base relative
addressing, but if I remember there was a 64K limitation for offsets
isn't there?   I was thinking with enough compiler support, you could

Yes, a +/- 32K limit on short offsets. Of course 68020 and up also supports long offsets.

emulate page tables in software on a module-by-module basis keeping each
module of code under 64K.  Jumps within a module should be fine, but
jumps between modules would look up the function to call through a table
which the OS would have to provide to each process.  Heap data
(everything not in a register or on the stack) would also have to be
accessed through such tables so the OS can allocate the non-shared data
segments per-process.  Modules can be shared and linked at run-time as
long as no function is > 64K.  Shared libraries would consist of
multiple modules.

This has been done before, for other chip architectures. The gcc support for MIPS has the notion of a .smalldata segment, for example, which is used to store small variables. And all platforms use tables of function pointers to implement shared libraries.

I don't see any reason to treat the heap specially. Pointers are still just pointers. The only thing that needs special treatment are direct address references.

You could even have the OS "swap-out" functions and data from the table
and replace the table entry for that function with a non-existent
pointer.  When a BUS ERROR occurs on that pointer, put the task on a
wait queue, look up that pointer in a table to find the function that
was swapped out, and swap it back in, then start the process at that
function.

Servicing a Bus Error exception here is needlessly slow. You can handle this the same way as lazy resolution in other systems - set the pointer to point to the system's dynamic loader, so it will do the lookup as needed.

Now ... it could all work, but obviously its not going to be as
efficient and robust as just using the MMU, and you wouldn't need
compiler teaks to generate all the table lookups.  However, it may be
doable quicker easier than MMU code and would work on a plain 68000.
I'm just interested in your thoughts at this point.

It will not be as robust since you won't be using the MMU's memory protection features, but it will in fact be more efficient most of the time since short offset base-relative addressing modes are the most efficient on the 68K architecture.

--
  -- Howard Chu
  Chief Architect, Symas Corp.  http://www.symas.com
  Director, Highland Sun        http://highlandsun.com/hyc
  OpenLDAP Core Team            http://www.openldap.org/project/