home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
memmon.zip
/
TEST.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1997-05-10
|
1KB
|
69 lines
program TestStk2;
{$X+,D+,Locinfo+}
Uses
MemMon, Os2Base, VPUtils;
function SomeFunction(x: Longint): String;
begin
if x = 0 then
Result := 'x is 0'
else if x > 0 then
Result := 'x is greater than 0'
else
Result := 'x is less than 0'
end;
function FacFunc(p: Pointer): Longint;
var
x: Longint absolute p;
BadPtr: Pointer;
begin
if x < 0 then
begin
SomeFunction(x);
GetMem(BadPtr, 500);
FacFunc := 0;
end
else
if x = 0 then
begin
Getmem(BadPtr, 21);
FacFunc := 1
end
else
FacFunc := FacFunc(Ptr(x-1))*x;
end;
var
tid1, tid2 : Longint;
p: Pointer;
begin
{ Allocate some memory to lose }
GetMem(P, 100);
{ Allocate some memory, and free it later }
GetMem(P, 88);
{ Start a few threads }
tid1 := VPBeginThread(FacFunc, 8192, Ptr(10));
tid2 := VPBeginThread(FacFunc, 8192, Ptr(-2));
{ Wait for all threads to complete }
DosWaitThread(tid1, dcww_Wait);
DosWaitThread(tid2, dcww_Wait);
{ Free the memory allocated earlier }
FreeMem(P, 88);
{ Display standard report }
DisplayStandardData;
end.