TestLupineRuntimeImplBuffers.mesa
Last Edited by: Bob Hagmann, February 11, 1985 10:02:39 am PST
DIRECTORY
BasicTime,
Random,
RPCLupine;
TestLupineRuntimeImplBuffers: PROGRAM
IMPORTS BasicTime, Random, RPCLupine
= {
Declarations
bufferRec: TYPE = RECORD [
address: LONG POINTER,
size: CARDINAL ← 0
];
bufferArray: ARRAY [1..128] OF bufferRec;
freeRover: CARDINAL ← 1;
maxListSize: INT = 7; -- Maximum size kept in the cache
Test Procedures
Test: PROC = {
startTime: BasicTime.GMT = BasicTime.Now[];
[] ← Random.Create[];
WHILE BasicTime.Period[startTime, BasicTime.Now[]] < 30 DO
noAllocs: CARDINAL = Random.ChooseInt[min: 1, max: 5];
noScan: CARDINAL = Random.ChooseInt[min: noAllocs, max: noAllocs*3];
FOR free: CARDINAL IN [1..noScan] DO
IF bufferArray[freeRover].size # 0 THEN {
RPCLupine.DeAlloc[bufferArray[freeRover].address, bufferArray[freeRover].size];
bufferArray[freeRover].size ← 0;
};
freeRover ← freeRover + 1;
IF freeRover > 128 THEN freeRover ← 1;
ENDLOOP;
FOR alloc: CARDINAL IN [1..noAllocs] DO
size: CARDINAL = Random.ChooseInt[min: 1, max: 8] * 256;
address: LONG POINTER TO WORD ;
probe: CARDINAL;
address ← RPCLupine.Alloc[size];
probe ← Random.ChooseInt[min: 1, max: 128];
DO
IF bufferArray[probe].size = 0 THEN {
bufferArray[probe].size ← size;
bufferArray[probe].address ← address;
EXIT;
};
probe ← probe + 1;
IF probe > 128 THEN probe ← 1;
ENDLOOP;
ENDLOOP;
ENDLOOP;
FOR free: CARDINAL IN [1..128] DO
IF bufferArray[free].size # 0 THEN {
RPCLupine.DeAlloc[bufferArray[free].address, bufferArray[free].size];
bufferArray[free].size ← 0;
};
ENDLOOP;
};
}.
Bob Hagmann February 11, 1985 10:01:22 am PST
changes to: DIRECTORY, TestLupineRuntimeImplBuffers, Test