[net.micro.amiga] MMUs and program correctness

pickle@nmtvax.UUCP (11/11/85)

neil@amiga.UUCP from Commodore-Amiga Inc. writes:
>Multitasking does NOT require an MMU.  Processes are allocated separate
>places in memory, and then are timesliced (the same way one would if one
>did have an mmu...).  There is no protection between different processes.
>One could write a program that trashes memory, and therefore the system
>(hence the infamous "GURU MEDITATION...").
>Correctly written programs run without any problems, however.

    Whoa!!  The way *I* would phrase it is "Multitasking does not require
an MMU, but it's a good idea to have one."  A few questions on this: does
the OS take care of memory allocation while a program is running, or
only when loading?  For example, I write a quick sort in C that I want
to keep around in background.  Every once in a while, I feed it source
and destination files, the program mallocs a bunch of space, sorts,
writes, then frees the space.  When I call malloc, does the OS handle
it, or does the C compiler put in code to grab whatever looks good?
If the actual code is ~5k, and I read in 50k of data, will this cause
a problem?
    From a development point of view, this scheme is really bad: nothing
would frost my cookies more than having to reboot the system because
I looked at a bad pointer and a program I was writing decided to munch
some chunk of memory.  What makes it worse than other micros?  Imagine
that I store variable x in the middle of my editor.  The program stops,
I go to edit the program, and the machine takes a holiday.  Multitasking
while developing might not be a good idea....
    Of course none of this happens because we all write programs correctly,
right? %\' (Impressionist smile)
    On a lighter note, I recall reading that the Joyboard (a joystick
you stand on) was being used to generate capital for a high powered
graphics/sound computer.  The Amiga wouldn't happen to have any relation
to this, would it?

Patrick "Pickle" Madden, in Scenic Socorro (It's worth the stop)
!cmcl2!lanl!unmc!nmtvax!pickle  "You needn't be well to be wealthy,
!ucbvax!unmvax!nmtvax!pickle     But you've got to be whole to be holy"

bruceb@amiga.UUCP (Bruce Barrett) (11/14/85)

In article <862@nmtvax.UUCP> you ask:
>					A few questions on this: does
>the OS take care of memory allocation while a program is running, or
>only when loading?  For example, I write a quick sort in C that I want
>to keep around in background.  Every once in a while, I feed it source
>and destination files, the program mallocs a bunch of space, sorts,
>writes, then frees the space.  When I call malloc, does the OS handle
>it, or does the C compiler put in code to grab whatever looks good?
>If the actual code is ~5k, and I read in 50k of data, will this cause
>a problem?

	The answer is:  The OS (AmigaDOS) allocates memory for code, data,
and bss (uninitialized data) at the time your program is loaded.  YOU have
the option of declaring 50k of arrays within your program (very wasteful,
not very flexible) --or-- requesting (and releasing) memory from the OS
as you need it (much better).  The memory you request can be either "chip"
memory or "fast" memory.  Chip memory is the memory that the custom VLSI
chips have access to (0k to 512k).  Fast memory is the other 8 meg (.5meg
to 8.5meg).  If there is not enough "fast" memory to satisfy your request
(maybe you "only" have 512k of RAM) the system will allocate chip memory,
if available.  Remember that there is no contention between the VLSI
chips and "Fast" memory.  The choice is yours.

	The exec functions to use are "AllocMem" and "FreeMem".  These
are available from Assem and C. They allow you to specify memory type.
The ROM Kernel Manual documents these.

	The 'C' runtime support uses "malloc", "calloc", "free", "getmem", 
"getml", "rlsmem", and "rlsml".  I believe that they allocate "fast"
memory.  In any event they do NOT allow you to specify RAM type.
The "Lattice C Compiler Manual" documents these.

	System calls (AvailMem) allow you to determine the total amount of 
free memory for any/all types, as well as the largest contiguous piece(s) 
available.

-- Bruce Barrett

john@anasazi.UUCP (John Moore) (11/15/85)

In article <862@nmtvax.UUCP> pickle@nmtvax.UUCP writes:
>neil@amiga.UUCP from Commodore-Amiga Inc. writes:
>>Multitasking does NOT require an MMU.  Processes are allocated separate
>>places in memory, and then are timesliced (the same way one would if one
>>did have an mmu...).  There is no protection between different processes.
>>One could write a program that trashes memory, and therefore the system
>>(hence the infamous "GURU MEDITATION...").
>>Correctly written programs run without any problems, however.
>
>    From a development point of view, this scheme is really bad: nothing
>would frost my cookies more than having to reboot the system because
>I looked at a bad pointer and a program I was writing decided to munch
>some chunk of memory.  What makes it worse than other micros?  Imagine

	Let me describe my experience with a very similar situation. I
run Venix (a licensed UNIX) on a PC/AT in 8086 (unprotected) mode. For
the last two days I fought a problem where a complex application involving
multiple processes was tubing the whole system. Makes it hard to find a
problem when the system develops amnesia immediately after the problem
occurs. Even worse, one runs the risk of trashing the disk (happened
once so far). This is on a machine with LIMITTED memory protection -
most wild memory stores will fall within 64k of the start of a valid
segment, rather than into the monitor.
	PLEAZE - next time someone brings out a machine with 32 bit
addressability, PLEASE put in an MMU. Then mere mortals can write
and debug programs under Unix or other multitasking OS's, without
"correctly written programs." Have you ever seen a significant
program correctly written the first time???

-- 
John Moore (NJ7E/XE1HDO)
{decvax|ihnp4|hao}!noao!terak!anasazi!john
{hao!noao|decvax|ihnp4|seismo}!terak!anasazi!john
(602) 952-8205 (day or evening)
5302 E. Lafayette Blvd, Phoenix, Az, 85018 (home address)

tim@ISM780B.UUCP (11/19/85)

In an article by john@anasazi in net.micro.amig he says:

>         PLEAZE - next time someone brings out a machine with 32 bit
> addressability, PLEASE put in an MMU. Then mere mortals can write
> and debug programs under Unix or other multitasking OS's, without
> "correctly written programs." Have you ever seen a significant
> program correctly written the first time???

And software people, PLEAZE - next time the hardware guys give you an MMU,
use the shpxvat(ROT 13) thing!