Amiga.org

Amiga computer related discussion => Amiga Hardware Issues and discussion => Topic started by: trekiej on June 20, 2008, 03:10:45 AM

Title: Amiga Memory Mangement
Post by: trekiej on June 20, 2008, 03:10:45 AM
Can some one tell me about memory management on the Amgia?
Some 68K cpu's had a MMU and some do not.
Thanks.
Title: Re: Amiga Memory Mangement
Post by: rkauer on June 20, 2008, 03:37:46 AM
Quote

trekiej wrote:
Can some one tell me about memory management on the Amgia?
Some 68K cpu's had a MMU and some do not.
Thanks.


 MMU have nothing to do in the memory management area.

 Memory is controlled by Alice/Agnus (chip RAM) and for the CPU itself (fast memory). The amount of RAM depends on the CPU address lines (24 bits on 68000, 010 and EC020 CPUs = 16Mb, where 8Mb is already taken by the Amiga chipset), up to 4Gb in 32bit CPU (full 020, 030 and over).

 But this is not fully implemented in hardware since you need:

 - a lot of mux/demux chips to route the RAM chips;

 - too much hassle to design a board with more than 128Mb using 72pin SIMM (newer memory banks must a new, designed from scratch, memory address controller). :headwall:
Title: Re: Amiga Memory Mangement
Post by: weirdami on June 20, 2008, 04:13:17 AM
MMU = math thingy?
Title: Re: Amiga Memory Mangement
Post by: Piru on June 20, 2008, 04:34:14 AM
@trekiej

On the software side, the amiga memory system is simple first fit (http://www.memorymanagement.org/glossary/f.html) allocation system. It is a global memory system (that is all tasks/processes share the same global memory pool). Basically this means that many applications are programmed in a way that they access each others memory at will, making it impossible to introduce memory protection (via MMU) without breaking the binary compatibility. The closest you can get is system provided by the mmu.library (http://aminet.net/package/util/libs/MMULib).

First fit allocators slow down exponentially due to memory fragmentation, the problem made worse by the global memory system. The effects of the fragmentation can be reduced with a better allocator however: for example two level segregate fit (http://rtportal.upv.es/rtmalloc/). There's a great AmigaOS 3.x implementation by Chris Hodges: TLSFMem.lha (http://www.platon42.de/files/util/TLSFMem.lha). Note that while TLSF does reduce fragmentation it doesn't remove it completely. However the fragmentation still remaining will have no effect on the allocation/deallocation performance.

PS. Fix that keyboard... :-)

@weirdami
Quote
MMU = math thingy?

No. Wikipedia: Memory Management Unit (http://en.wikipedia.org/wiki/Memory_management_unit)
Title: Re: Amiga Memory Mangement
Post by: trekiej on June 20, 2008, 04:45:44 AM
@ Piru:
It is the operator.  :-D

I feel that Zorro cards use AutoConfig.
Is there a situation where someone would use TTL chips to make a card work at a specific location?

Title: Re: Amiga Memory Mangement
Post by: rkauer on June 20, 2008, 05:03:06 AM
Quote

trekiej wrote:

I feel that Zorro cards use AutoConfig.
Is there a situation where someone would use TTL chips to make a card work at a specific location?


 Nope. In the case of the autoconfig cards, there is a 64kb memory area on big-box Amigas to settle the card ID and small settings.
Title: Re: Amiga Memory Mangement
Post by: trekiej on June 20, 2008, 05:26:12 AM
@rkauer: That leads me to believe that one would have to access that info. through the kernel or hardware to get the location of the PIC's address.
I need to finish reading Zorro3 manual.
 :-D
Title: Re: Amiga Memory Mangement
Post by: rkauer on June 20, 2008, 07:10:29 AM
 No need to.

 I'm certain someone (like Piru ;-)) have this information in the his mouth/fingers right now. :-)
Title: Re: Amiga Memory Mangement
Post by: Piru on June 20, 2008, 07:18:18 AM
The Amiga Hardware Reference Manual should have the Zorro(R) AUTOCONFIG(TM) (http://en.wikipedia.org/wiki/AutoConfig) explained pretty well.
Title: Re: Amiga Memory Mangement
Post by: alexh on June 20, 2008, 07:43:42 AM
Quote

Piru wrote:
@trekiej
Two level segregate fit. There's a great AmigaOS 3.x implementation by Chris Hodges: TLSFMem.lha (http://www.platon42.de/files/util/TLSFMem.lha).

Shame it was not finished, it had so much promise. It still has one or two bugs in it which make it a little incompatible with some programs. I heard that someone had taken over this project, renamed it MemTLSF, but I have seen no more releases.
Title: Re: Amiga Memory Mangement
Post by: Piru on June 20, 2008, 08:01:13 AM
@alexh
Quote
It still has one or two bugs in it which make it a little incompatible with some programs.

What kind of bugs exactly? Would be interesting to do last minute testing of the MOS 2.0 TLSF memsystem I wrote (it's not based on Chris' code but shares much of the ideas, so it might also share bugs).
Title: Re: Amiga Memory Mangement
Post by: Damion on June 20, 2008, 08:19:31 AM
I get recoverable alerts with a few programs, for example the old Chris Hames "Degrader" program gives me a "715F 0041", system eventually returns with around -530,000,000 fast mem available, and will generally crash for good shortly after, LOL.  

I've found it's fine 99% of the time though, and I have _no_ clue whether it's a TLSFmem bug or bugged program.

Title: Re: Amiga Memory Mangement
Post by: Piru on June 20, 2008, 08:47:36 AM
I would imagine that's just Degrader doing some rather nasty tricks, it's quite hacky program after all.
Title: Re: Amiga Memory Mangement
Post by: alexh on June 20, 2008, 09:57:10 AM
Quote
Wepl wrote:
It seems that TLSF returns 2,018,011,950 for AvailMem(MEMF_LARGEST).

Which causes nothing to be preloaded in WHDLoad as it uses this to calculate the puddle size for the memory pools used for the PreLoad memory.


http://eab.abime.net/showthread.php?t=33790
Title: Re: Amiga Memory Mangement
Post by: Piru on June 20, 2008, 10:07:27 AM
@alexh

Ok, no such problem in mine.
Title: Re: Amiga Memory Mangement
Post by: weirdami on June 20, 2008, 12:14:51 PM
Quote

Piru wrote:

Quote
MMU = math thingy?

No. Wikipedia: Memory Management Unit (http://en.wikipedia.org/wiki/Memory_management_unit)


That's what I figured, but then

Quote
MMU have nothing to do in the memory management area.


happened.
Title: Re: Amiga Memory Mangement
Post by: Piru on June 20, 2008, 01:30:41 PM
@weirdami

Check the thread topic it has a crucial keyword in it :-)
Title: Re: Amiga Memory Mangement
Post by: Crumb on June 20, 2008, 01:49:19 PM
Quote

Piru wrote:
@alexh

Ok, no such problem in mine.


mmmm I can't wait to put my dirty paws on MOS2.0! ;-)
Title: Re: Amiga Memory Mangement
Post by: Damion on June 20, 2008, 06:47:54 PM
Quote

Piru wrote:
I would imagine that's just Degrader doing some rather nasty tricks, it's quite hacky program after all.


That would make sense. Only other program I can recall (same error) was AIBB benchmark, which is probably also bugged.

Everything else, hundreds of demos, games (no problem with WHDLoad here), utilities, etc work fine.

 
Title: Re: Amiga Memory Mangement
Post by: Piru on June 21, 2008, 09:20:43 AM
Just tried AIBB, and the allocator debug tells me it tries to FreeMem 34 bytes when it allocated much larger chunk. That's bad.