Oberon Community Platform Forum
December 14, 2019, 05:33:50 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: AWAIT outside of EXCLUSIVE  (Read 4583 times)
mas
Newbie
*
Posts: 2


« 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:

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

Had to be replaced by

Code:
REPEAT
   Objects.Yield; (*Objects replaced former AosActive*)
UNTIL ( (con.Available()>0) OR con.state#AosTCP.Established);
Logged
felix
Administrator
Newbie
*****
Posts: 17



WWW
« Reply #1 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).


PROCEDURE SharedProc;
BEGIN
 AWAIT(condition)
END SharedProc;

PROCEDURE ExclusiveProc;
BEGIN{EXCLUSIVE}
(* ... *)
SharedProc;
(* ... *)
END ExclusiveProc;
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #2 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!