Oberon Community Platform Forum

Development => Bug Report => Topic started by: mas on February 01, 2008, 08:30:02 AM

Title: AWAIT outside of EXCLUSIVE
Post by: mas on February 01, 2008, 08:30:02 AM
The compiler just gives a warning - but it definitely and reproduceably freezes the system. Make it an error.

Just for information, here the code that crashed:

con: AosTCP.Connection
AWAIT ( (con.Available()>0) OR (con.state#AosTCP.Established));

Had to be replaced by

   Objects.Yield; (*Objects replaced former AosActive*)
UNTIL ( (con.Available()>0) OR con.state#AosTCP.Established);

Title: Re: AWAIT outside of EXCLUSIVE
Post by: felix on February 01, 2008, 06:00:40 PM
The Problem is that the non-existence of an embracing exclusive section cannot be proved during compile time.
Consider the following code. It is bad style but semantically ok (at present).
Should it be forbidden? (It certainly could if reentrant locks were present).

END SharedProc;

PROCEDURE ExclusiveProc;
(* ... *)
(* ... *)
END ExclusiveProc;

Title: Re: AWAIT outside of EXCLUSIVE
Post by: staubesv on February 03, 2008, 10:06:07 AM
An additional note on this:

Assuming that your code containing the AWAIT statement is not located in the AosTCP.Connection object but another object , say object A, your code does not work even if you put the AWAIT statement into an EXCLUSIVE block:

If the condition ( (con.Available()>0) OR (con.state#AosTCP.Established) ) is not TRUE when a thread executes the AWAIT, the thread would be put into the (hidden) awaitingCond process queue of the object A instance.
If now the state of the AosTCP.Connection con would change so that the condition is satisfied, the thread would not be woken up.
Why? Its condition is only re-evaluated when a thread leaves a critical section (EXCLUSIVE block) of that particular object A instance, i.e. the thread won't notice a state change of the AosTCP.Connection con.

The basic assumption for the AWAIT statement is that you're waiting on a object state change of the object where the AWAIT statement is located.