SystemV- Heap + Module Space
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 ; with: 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.
On Sun, 30 Dec 2018 22:53:50 +0100 Andreas Pirklbauer <andreas_pirklbauer@yahoo.com> wrote:
It depends on what heuristics you want to use to find the gap.
Many thanks, I see the argument about usefulness, but is a nice toy exercise. Also, based on similar idea, the trivia of Apple Macintosh memory management was built, around time, when 640K was a limit under DOS. -- Tomas Kral <thomas.kral@email.cz>
It depends on what heuristics you want to use to find the gap.
Hi, Thank you. I am testing a new core with these changes in `Modules.Mod' [1] PROCEDURE Load* ... IF res = 0 THEN (*search for a hole in the list allocate and link - BOTTOM -> TOP*) INC(size, DescSize); (*mod*) m := root; mod := NIL; (*WHILE (mod # NIL) & ~((mod.name[0] = 0X) & (mod.size >= size)) DO mod := mod.next END ;*) WHILE m # NIL DO IF (m.name[0] = 0X) & (m.size >= size) THEN mod := m END ; m := m.next END ; The above works as expected, modules are filled in holes bottom up fashion which I believe conserves module store better then then top bottom approach. Is there a system pointer marking modules' origin? mod := org; WHILE (mod # root) DO mod := mod.next END ; [2] PROCEDURE Free* ... IF mod = root THEN (*increase size of available module space*) p := mod.size; mod := mod.next; WHILE (mod # NIL) & (mod.name[0] = 0X) DO INC(p, mod.size); mod := mod.next END ; AllocPtr := AllocPtr - p; root := mod END ELSE res := 1 ... The above has sometimes problems, cannot figure out why yet. I tried commenting (*mod # NIL) &*). It sometimes locks the system. -- Tomas Kral <thomas.kral@email.cz>
Tomas Generally, System.Free is not safe. Here some examples where Free might freeze the system: - if you installed a background task in the Oberon loop and unload the handler module without having deinstalled the task handler first. - If you use call back procedures in you modules, and unload only half of your modules. As the added code decreases AllocPtr, the probablitity that subsequent module loads overwrite still referenced code increases. I assume the freeze is not caused by the added lines per se, but rather that you freed some modules that should not be freed. br Jörg Am 01.01.19, 16:06 schrieb "Oberon im Auftrag von Tomas Kral" <oberon-bounces@lists.inf.ethz.ch im Auftrag von thomas.kral@email.cz>: > It depends on what heuristics you want to use to find the gap. Hi, Thank you. I am testing a new core with these changes in `Modules.Mod' [1] PROCEDURE Load* ... IF res = 0 THEN (*search for a hole in the list allocate and link - BOTTOM -> TOP*) INC(size, DescSize); (*mod*) m := root; mod := NIL; (*WHILE (mod # NIL) & ~((mod.name[0] = 0X) & (mod.size >= size)) DO mod := mod.next END ;*) WHILE m # NIL DO IF (m.name[0] = 0X) & (m.size >= size) THEN mod := m END ; m := m.next END ; The above works as expected, modules are filled in holes bottom up fashion which I believe conserves module store better then then top bottom approach. Is there a system pointer marking modules' origin? mod := org; WHILE (mod # root) DO mod := mod.next END ; [2] PROCEDURE Free* ... IF mod = root THEN (*increase size of available module space*) p := mod.size; mod := mod.next; WHILE (mod # NIL) & (mod.name[0] = 0X) DO INC(p, mod.size); mod := mod.next END ; AllocPtr := AllocPtr - p; root := mod END ELSE res := 1 ... The above has sometimes problems, cannot figure out why yet. I tried commenting (*mod # NIL) &*). It sometimes locks the system. -- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
As the added code decreases AllocPtr, the probablitity that subsequent module loads overwrite still referenced code increases.
Joerg, Andreas, I see, thank you for explaining. Is just part of my exploring & learning. Re Type descriptors kept in mem. Running GC, just after unloading and before next loading, will it increase this quazzy safety? I am sensible as far as unloading modules from the inner core. But I admit, I tried unloading EDIT module, that at first sight appears save to free, when there is no file opened in a user viewer so perhaps nothing is referenced. But proved the opposite. Many thanks. -- Tomas Kral <thomas.kral@email.cz>
participants (3)
-
Andreas Pirklbauer -
Jörg -
Tomas Kral