Article View: comp.sys.transputer
Article #473Re: Dynamically determining memory size
From: Richard Ohran
Date: Thu, 18 Jan 1990 00:30
Date: Thu, 18 Jan 1990 00:30
44 lines
1748 bytes
1748 bytes
Here is a procedure written in Modula-2 which finds all the memory
between the top of the process and the top of memory.
It returns the starting address in the variable "adr" and the
number of available bytes in "size". It checks for both
memory wraparound and non-existent memory address regions.
PROCEDURE Allocate(VAR adr: POINTER TO BITSET; VAR size: CARDINAL);
VAR x: POINTER TO ProcessState;
z,zchanged:BITSET;
b:POINTER TO BITSET;
BEGIN (*size is in bytes*)
InitProcessPtr(x);
adr:=x^.ProcessTop; (* adr now has the first memory address above
the running program*)
size:=0;
LOOP
INC(adr,200H);
b:=CARDINAL(adr) MOD 10000H + 80000000H; (*creating wraparound address*)
IF adr^=b^ THEN (*potential memory wraparound*)
z:=adr^;
zchanged:=z/{0..31}; (*exclusive or*)
adr^:=zchanged;
IF adr^=b^ THEN (*wraparound*)
adr^:=z;
EXIT
END
END;
(*now check for non-existent memory*)
z:=adr^;
z:=z/{0..31}; (* exclusive or*)
adr^:=z;
IF adr^<>z THEN EXIT END;
adr^:= z/{0..31};(*restore data for valid word*)
INC(size,200H);
END;
adr:=x^.ProcessTop;
END Allocate;
Hope this helps. If you have any questions about how it
works, call me at 801-226-8978.
Richard Ohran
Technical Details
Message-ID:
<9001180030.AA27876@adam.byu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ADAM.BYU.EDU!rohranShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ADAM.BYU.EDU!rohran From: rohran@ADAM.BYU.EDU (Richard Ohran) Newsgroups: comp.sys.transputer Subject: Re: Dynamically determining memory size Message-ID: <9001180030.AA27876@adam.byu.edu> Date: 18 Jan 90 00:30:15 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 44