Solar wrote:
It is perfectly possible to have a fully multitasking OS in absence of an MMU, if your OS is designed to support it (and your hardware can fire a timer interrupt for the scheduler).
I was thinking about the timer and it's absense... parhaps even without an internal timer, but provided that the architecture supports interrupts and you have an interrupt driven serial port, you could wire an external timer that would send some signal to the serial port to interrupt the processor...
Another solution is of course making the kernel interpret the programs (written in some special language or not) and implement all the necessary things in the interpreter... But it's like creating an emulator, cause your program wouldn't be really running in the native architecture!
And... An alternative solution that would solve many of these problems would be asking the processor to do single-step execution and emulating memory access... (another poor solution!)
It makes certain things trickier - you need support for PIC (position-independent code); a binary format that has proper relocation tables,
I think that's the classical way to load programs in archs without MMU...
If the architecture doesn't support executing PIC eficiently, then parhaps the best choice is relocation tables...
and ideally allows splitting up a binary into smaller parts so you don't need a chunk of continuous memory as big as your complete binary;
I'm not quite sure there is an executable format designed to do this!
a loader that does relocations while loading a binary; and offset tables for your library functions so they can still be shared.
In my (purely theoric) opinion, address space sharing makes it much simpler to implement shared libraries than with address space separation...
That's because if you have everything in the same address space then you only need to do load time linking, cause it isn't necessary to find free memory in the address spaces of each process that uses the library...
For example (and the sizes are examples too!), if your Linux app uses glibc (1 KB) and GTK+ (5KB), the kernel will map and relocate one after the other (if the kernel maps shared libraries starting at 0x10000000, GLIBC would be from 0x10000000 to 0x10000400 and GTK+ from 0x10001000 (page aligned...) to 0x10002400)...
If you execute another program that needs the same libraries... the kernel can reutilize the pages with the relocated libraries loaded in it...
Now suppose that there is another program that doesn't need GLIBC, but instead uses another library, that consumes 6KB (a page and a half), and also GTK+... the kernel will need to either reload and relocate GTK+ to one page forwards from the previous location or relocate and map the 6KB libarary at 0x10003000...
Though, I think it's not a very common problem...
JJ
PS: I'm too lazy now to review my post, so don't strange if you read a lot of errors!