|
From: | address@hidden |
Subject: | [Gm2] [GM2] Iso Module "Processes" - Bug report |
Date: | Sun, 20 Mar 2016 20:51:16 +0100 (MET) |
Hello Gaius, all,
below please find some sample code on how to use the "Processes" module from the ISO libraries. In order to make it run, I had to fix some minor bugs in "Processes.mod". The diff, the complete "Processes.mod" and the complete test module are attached.
Compile with:
gm2 -lpth -g -o TestProcesses -fmakeall -fiso -flibs=iso,pim TestProcesses.mod
Tested on Ubuntu 14.4 64 bit on Intel Hardware.
Feel free to use the code in any way you find appropriate, I do not claim any rights on it.
Thanks and regards, Georg
MODULE TestProcesses;
TYPE ParameterRec=RECORD
Card:CARDINAL;
Chars:ARRAY[0..20] OF CHAR;
Parent:ProcessId;
END;
TYPE ParameterPtr=POINTER TO ParameterRec;
PROCEDURE Hello();
VAR ChildId:ProcessId;
DataPtr:ParameterPtr;
Para:Parameter;
BEGIN
Log("Hello Client");
ChildId:=Me();
LogP2("ProcessId of Child is ",ChildId);
Para:=MyParam();
LogP1("Parameter address in Child ",Para);
DataPtr:=CAST(ParameterPtr,Para);
Log("Did the cast");
IF DataPtr=NIL
THEN
Log("Param is nil");
HALT;
END;
(* Use current parameter values *)
WriteString(DataPtr^.Chars);
WriteLn();
WriteCard(DataPtr^.Card,10);
WriteLn();
DataPtr^.Card:=27; (* Change a value *)
SuspendMeAndActivate(DataPtr^.Parent); (* without patch: Assert failed *)
END Hello;
VAR ChildId:ProcessId;
Data:ParameterRec;
DataPtr:Parameter;
BEGIN
Log("Starting Test");
Data.Parent:=Me();
LogP2("Id of parrent ",Data.Parent);
Data.Card:=42;
Data.Chars:="This is Data ";
DataPtr:=ADR(Data);
LogP1("Parameter address in Parent ",DataPtr);
Start(Hello,100000,10,DataPtr,ChildId);
LogP2("Returned. Id of Child ",ChildId);
WriteString("Parameter value in Parent ");
WriteCard(Data.Card,10);
WriteLn();
END TestProcesses.
Processes.diff
Description: Text Data
Processes.mod
Description: audio/mod
TestProcesses.mod
Description: audio/mod
[Prev in Thread] | Current Thread | [Next in Thread] |