Development : : Article on the New MorphOS Memory System
Posted By: ASiegel. on 2009/2/9 22:12:16
Article on the New MorphOS Memory System

Harry "Piru" Sintonen wrote a development article about the new MorphOS memory system that was first introduced with MorphOS 2.0. It provides an in-depth view on the overall design goals and technical implementation.

You can read the entire article by clicking this link.

 
  • Order of the Butterfly
    Order of the Butterfly
    AyoS
    Joined: 2003/8/13
    Posts: 410
    From: West Palm Beac...
    Very Informative... I had noticed a definite difference between how memory was handled between 1.4 & 2.0. Now I understand even more. Thank You (x2)
  • »2009/2/10 1:47
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    jcmarcos
    Joined: 2003/3/13
    Posts: 1178
    From: Pinto, Madrid ...
    Great read, even if I don't understand it completely... By the way, the new allocation method seems to be an spanish invention!
  • »2009/2/10 7:21
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Yomgui
    Joined: 2004/8/31
    Posts: 348
    From: Québec ...
    The brain frighten me! That's a gore news! :-D
    And now... next project!
  • »2009/2/10 7:44
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    MarK
    Joined: 2004/1/25
    Posts: 641
    From: Prague, The Cz...
    please include in MorphOS 3 or 4 memory defragmentation, then it will be usable for...ever :)

    bye, MarK.
  • »2009/2/11 7:22
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    AmigaMancer
    Joined: 2005/8/25
    Posts: 265
    From:
    This new allocation method was first implemented in classic AmigaOS long before it was ported to MorphOS 2 and it is called TLSFMem. A shame that noone decided to publicate this port for registered 1.4.5 users.

    [ Edited by AmigaMancer On 2009/2/11 15:22 ]
    Amiga 1200 user.
  • »2009/2/11 12:21
    Profile
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Leif
    Joined: 2006/5/31
    Posts: 111
    From: Sweden
    "This new allocation method was first implemented in classic AmigaOS long before it was ported to MorphOS 2 and it is called TLSFMem. A shame that noone decided to publicate this port for registered 1.4.5 users."

    It was'nt ported to MorphOS 2, it was written from scratch. The AmigaOS version is written in 68k assembler.
    And I doubt the MorphOS 2 version would work on 1.4.5 (as is) because it integrates deeply into MorphOS 2.
  • »2009/2/11 17:48
    Profile
  • MorphOS Developer
    Piru
    Joined: 2003/2/24
    Posts: 506
    From: finland, the l...
    @AmigaMancer
    Quote:

    This new allocation method was first implemented in classic AmigaOS long before it was ported to MorphOS 2 and it is called TLSFMem.

    Platon42 indeed did it before for m68k. When I was working on the new MorphOS memory system he even provided me with the source code to TLSFMem (but at that point I had already written my implementation pretty much, so I didn't end up using his code at all). His source code is in 68k asm indeed and with german comments (damn you german coders, comment in english will you :-)), while MorphOS memory system is C with some PPC inline asm optimizations.

    Quote:

    A shame that noone decided to publicate this port for registered 1.4.5 users.

    It isn't a port. It cannot exist as a patch either, so no version for 1.4.5 users.

    In theory TLSFMem kind of patcher could be written for MorphOS aswell, but it's a bit more complex than for OS 3.x (more allocation routines to support, for example the AllocMemAligned).
  • »2009/2/11 19:43
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    AmigaMancer
    Joined: 2005/8/25
    Posts: 265
    From:
    I wasn't aware of all these details. Ok.
    Amiga 1200 user.
  • »2009/2/11 21:01
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Chain-Q
    Joined: 2003/10/12
    Posts: 341
    From: 1 AU, EU, DE/HU
    @MarK:
    Quote:

    please include in MorphOS 3 or 4 memory defragmentation


    Even if you could defragment physical memory, it's no use, because can't defragment the address space. It's a different problem, if you think about it. You simply can't update pointers everywhere within compiled code. It's not even Amiga-related problem, other 32 bit systems hit the same limit. I know even badly written Windows and Linux applications which have serious problems running even with 2GB RAM, since they have a very bad memory allocation scheme, which fragments their address space, and when the allocator runs out continous address space (again, *not* continous physical memory, but continous address range) for a large allocation, it will fail, and the application will crash. And there's no way you could defragment an address range, or update the pointers, except you're written in Java or other VM, which is a complettely different business. In fact, programmers were trained for years to avoid thinking about memory management issues, and now it strikes back with examples like that. No wonder Java is that popular, and many companies trying to force migration for 64 bit, which gives 64 bit address ranges to fragment, and it eliminates these problems from the way of bad coding practices. Of course it will need 10x as much computing resources, doing the same stuff as 5 years ago, but obviously, that's only good for most of the hardware companies.

    To sum it up, the only difference is, on other systems, the apps can only destroy their own address space, while on AmigaOS/MorphOS a single app can destroy the system's as well. But i can't see a way this could be fixed, without a full address separation per task, but that would be a fully different OS with totally destroyed backwards compatibility.

    At least this is how i now interpret this problem. But if i'm wrong i'm sure i'll stand corrected. :-)

    Ps: Any updates to PowerD? ;-)

    [ Edited by Chain-Q On 2009/2/12 14:43 ]
    [.PegasosII/G4.:.Efika.:.Amiga2000/060.]
    [.Free Pascal Compiler MorphOS Port.]
    [.Hosting AmigaSpirit.hu.]
  • »2009/2/12 12:38
    Profile Visit Website
  • Ex-Member
    Joined: 2004/6/15
    Posts: 74
    From:
    Quote:

    Platon42 indeed did it before for m68k. [...] His source code is in 68k asm indeed and with german comments (damn you german coders, comment in english will you :-)),


    While I agree that I'm a german bastard, I never ever have written my comments in german (at least not as far as I can remember, but my memory doesn't go back the whole 25 years), and also the TLSFMem source code is completely commented in english (and also all labels, etc.).

    But granted, this was in November 2007, so I don't blame you confusing me with some french guy (who usually comment in french, PITA).

    I also think you didn't start with the MorphOS TLSF implementation before my 68k implementation proved that it could be done :-P
    Bye...
    Chris Hodges
  • »2009/2/12 17:43
    Profile
  • MorphOS Developer
    Piru
    Joined: 2003/2/24
    Posts: 506
    From: finland, the l...
    @Platon42

    Ahhhh, indeed the PoolMem source had all german comments.

    Sorry, I'm old and senile :-)

    Quote:

    I also think you didn't start with the MorphOS TLSF implementation before my 68k implementation proved that it could be done

    That is correct, indeed. There was a new memory system, but back then it was nothing like TLSF. TLSFMem directly influenced many things.

    [EDIT] typo-- [/EDIT]

    [ Edited by Piru On 2009/2/15 3:09 ]
  • »2009/2/12 19:05
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    warface
    Joined: 2003/2/24
    Posts: 653
    From: Hungary
    Thanks for the article :)
  • »2009/2/12 20:08
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    magnetic
    Joined: 2003/3/1
    Posts: 2129
    From: Los Angeles
    Piru

    Interesting article...

    I think you need a gf :-P
    Pegasos 2 Rev 2B3 w/ Freescale 7447 "G4" @ 1ghz / 1gb Nanya Ram
    Quad Boot: MorphOS 2.7 | Amiga OS4.1 U4 | Ubuntu PPC GNU/Linux | OS X 10.4
  • »2009/2/14 5:24
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    r-tea
    Joined: 2005/3/27
    Posts: 291
    From: Poland, Zdzies...
    @ AmigaMencer
    A shame that noone decided to publicate this port for registered 1.4.5 users.

    After all 1.4.5 users can instal TLSFMem since it's 68k :)
    Mac mini G4@1,5GHz silent upgrade + HP Dj 595C + EPSON Perfection 1240U
    Amiga 600
    Commodore C64C + 2 x 1541II + Datasette + SD-Box

    I miss draggable screens... and do you? I know I'm in a minority unfortunately.
  • »2009/2/14 14:25
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    AmigaMancer
    Joined: 2005/8/25
    Posts: 265
    From:
    Quote:

    After all 1.4.5 users can instal TLSFMem since it's 68k :)

    That would be great given the fastness of Trance. Have you tried it yourself, though? If not, i would like to hear what Platon42 thinks of it.
    Amiga 1200 user.
  • »2009/2/14 14:35
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    MarK
    Joined: 2004/1/25
    Posts: 641
    From: Prague, The Cz...
    @Chain-Q:

    i ofcourse know about all these issues, and i spoke about it more-less as a joke :) any way, i was thinking about this stuff quite a lot, and i find no other way, than to make the memory sth like a ramdisk, i mean, that the continuous physical memory would be like a harddrive, there wouldn't be direct pointers, but... indirect pointers, that the system would work with. access to the memory would go only thru system calls, which will care about the fragmentation, this way could allocate single piece of memory from fragments (which ofcourse would very very slow, when accessing), but when this would happen, defragmentation routines would be called (by the OS itself), and the fragmentation will be fixed...

    it's still an idea, and it wouldn't work with old apps (perhaps it could work with some memory management), but else this is the way, the future will go... if we wanna unfragmented memory spaces (as i do)... now just to think out, how to make it fast, that it wouldn't cause long system lags... :)

    bye, MarK.

    ps: there were some internal PowerD updates, nothing really big, i'm very short on time... but i still believe, this will change (soon), and new PowerD releases will appear...
  • »2009/2/16 10:16
    Profile
  • Andreas_Wolf
    Joined: 2003/5/22
    Posts: 11465
    From: Germany
    > 1.4.5 users can instal TLSFMem since it's 68k

    AFAIK it doesn't work reliably on MorphOS. It is said to freeze after some time of usage.
  • »2009/2/16 18:58
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    AmigaMancer
    Joined: 2005/8/25
    Posts: 265
    From:
    @Andreas_Wolf
    I tried it briefly and didn't experience any problem with it, except of the known problem which also exists on AmigaOS 3. It is incompatible with WarpOS and so i un-installed it.
    Amiga 1200 user.
  • »2009/2/17 1:10
    Profile
  • ZB
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    ZB
    Joined: 2008/9/29
    Posts: 115
    From:
    Interesting article... thanks to Piru.

    The butterfly needs some highlighting...

    6j2hyq.jpg

    :-)

    [ Edited by ZB On 2009/2/24 10:52 ]
  • »2009/2/24 8:46
    Profile