Has AWAIT an error on linux?
I believe there is a problem with AWAIT in A2 running linux. Maybe only on linux as AWAIT is implemented in Unix.Objects.Mod.
Here is the description.
In the module below when I click on procedure 'start' active object gets
created and starts running.
Execution in procedure start() is paused in AWAIT.
When I now click on procedure terminate(), active object is terminated
and becomes an ordinary object.
This all is as it should be but the problem is that after clicking
procedure terminate() condition for AWAIT
is now true but AWAIT still hangs and procedure start() does not
continue (you can test it with procedure test()).
I have to click procedure terminate() for second time in order to get
procedure start() running after AWAIT (i.e. running n := 1 and
out.String("finished")).
Why do I have to click terminate() for second time in order to get
execution in start() past AWAIT? Is this an error?
Here is the module:
MODULE AwaitTest;
IMPORT out:=KernelLog, Objects;
TYPE
O = OBJECT
VAR
terminate,terminated: BOOLEAN;
BEGIN {ACTIVE}
WHILE terminate = FALSE DO
Objects.Sleep(500);
out.String(" active object running..."); out.Ln;
END;
terminated := TRUE;
out.String(" active object terminated."); out.Ln;
END O;
VAR
o: O;
n: INTEGER;
PROCEDURE terminate*();
BEGIN {EXCLUSIVE}
o.terminate := TRUE;
END terminate;
PROCEDURE start*();
BEGIN
NEW(o);
out.String("started"); out.Ln; n := 0;
BEGIN {EXCLUSIVE}
AWAIT(o.terminated);
END;
(* WHILE ~ o.terminated DO END; *)
n := 1;
out.String("finished");out.Ln;
END start;
PROCEDURE test*();
BEGIN
out.String("o.terminate="); out.Boolean(o.terminate); out.String(" n="); out.Int(n,0);out.Ln;
END test;
END AwaitTest.
System.Free AwaitTest ~
AwaitTest.start ~
AwaitTest.terminate ~
AwaitTest.test ~
(from redmine: issue id 118, created on 2022-03-08 by root)
- Uploads:
- AwaitTest.Mod Module testing AWAIT