startTime: BasicTime.GMT = BasicTime.Now[];
WHILE BasicTime.Period[startTime, BasicTime.Now[]] < 30
DO
noAllocs: CARDINAL = RandomCard.Choose[min: 1, max: 5];
noScan: CARDINAL = RandomCard.Choose[min: noAllocs, max: noAllocs*3];
FOR free:
CARDINAL
IN [1..noScan]
DO
IF bufferArray[freeRover].size # 0
THEN {
tpz.FREE[@bufferArray[freeRover].address];
bufferArray[freeRover].size ← 0;
};
freeRover ← freeRover + 1;
IF freeRover > 128 THEN freeRover ← 1;
ENDLOOP;
FOR alloc:
CARDINAL
IN [1..noAllocs]
DO
size: CARDINAL = RandomCard.Choose[min: 1, max: 8] * 256;
address: LONG POINTER ;
probe: CARDINAL;
DescriptorType: TYPE = RECORD [SEQUENCE COMPUTED CARDINAL OF WORD];
address ← tpz.NEW[DescriptorType[size]];
probe ← RandomCard.Choose[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;