tancheeh@fred.cs.washington.edu (Nicholas Tan Chee Hiang) (06/29/89)
I am trying to understand concurrency in Ada. Can someone please tell me why the variable Unprotected below is never updated? Thanks! - N ------------------------------>code below<------------------------------ with Text_IO; use Text_IO; procedure Unprotected_Shared_Variable is Unprotected : Character := '*'; pragma SHARED(Unprotected); task Write_Letter_A_To_Variable; task Access_Variable; task body Write_Letter_A_To_Variable is Letter : constant Character := 'A'; begin loop Unprotected := Letter; delay 0.5; end loop; end Write_Letter_A_To_Variable; task body Access_Variable is Letter : Character := Unprotected; begin loop Put (Letter); delay 3.0; end loop; end Access_Variable; begin null; end Unprotected_Shared_Variable;
guzzi@multimax (Mark D. Guzzi) (06/29/89)
Unprotected never appears to be updated because you read it once in task Access_Variable when you initialize Letter, then you never read it again. Try this instead: task body Access_Variable is -- Letter : Character := Unprotected; begin loop -- Put (Letter); Put (Unprotected); delay 3.0; end loop; end Access_Variable; -- -- Mark Guzzi Encore Computer Corporation guzzi@encore.com (or guzzi@multimax.encore.com)