[Oberon] SystemV- Heap + Module Space

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Sun Dec 30 22:53:50 CET 2018

   > Can you please just give me a small hint (*comment*) in the code for [a],[b], I will try then on my own.

It depends on what heuristics you want to use to find the gap. For example, if you just want to find
the very first block "at the lowest possible end that fits", simply replace the lines (in Modules.Load)

    mod := root;
    WHILE (mod # NIL) & ~((mod.name[0] = 0X) & (mod.size >= size)) DO
      mod := mod.next
    END ;


    m := root; mod := NIL;
    WHILE m # NIL DO
      IF (m.name[0] = 0X) & (m.size >= size) THEN mod := m END ;
      m := m.next
    END ;

If you really feel like it, you can also strengthen the condition in the IF statement
to find a gap that meets additional criteria, i.e. the “best possible fit”. You may also
think about splitting the gap into a “now re-used again” one and a “still not used”
portion, and about merging adjacent gaps (to keep fragmentation small).

A lot of ink has been spilled over questions like that --> you can make any
number of student exercises out of it...

But I question the usefulness of any of this in a system like Oberon.

More information about the Oberon mailing list