[Oberon] SystemV - Link Loader Strategy

Tomas Kral thomas.kral at email.cz
Wed Mar 6 18:00:25 CET 2019


Hi,

I am toying with best/sensible fit strategy, I am coding these lines.
Looking for improvements.

MODULE Fit; (*TK 6.3.2019, best fit strategy*)
  IMPORT SYSTEM, Modules, Files, In, Out;

  PROCEDURE Load*;
    VAR mod: Modules.Module; name: ARRAY 32 OF CHAR;
      size, ds, i, j: INTEGER; (*size delta*)
  BEGIN In.Open; In.Name(name); In.Int(size);

    (*1st pass*)
    mod := Modules.root; ds := 100H; (*heuristic granularity*) i := 0; j := -1;
    WHILE mod # NIL DO
      IF (mod.name[0] = 0X) & (mod.size-size >= 0) & (mod.size-size < ds) THEN ds := mod.size-size; j := i; END ;
      mod := mod.next; INC(i);
    END ;

    Out.Int(j, 4); Out.Ln; (*j > -1 sensible gap found*)

    (*2nd pass*) mod := Modules.root;
    WHILE j > 0 DO  mod := mod.next; DEC(j) END ;

    Out.String(mod.name); Out.Int(mod.size, 8); Out.Int(ds, 6); Out.Ln;

  END Load;
END Fit.

Fit.Load Screen 1388 ~



-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list