From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_05,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!amstel.llnl.gov!COSTELLO From: COSTELLO@amstel.llnl.gov Newsgroups: comp.lang.ada Subject: Reply to shared variable access . . . Message-ID: <8907031527.AA15125@ajpo.sei.cmu.edu> Date: 3 Jul 89 15:34:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: > Reply to Shared Variables question . . . -- -- Nicholas, -- The variable 'Letter' in the Access_Variable task is never being updated. -- It gets initialized to '*' (at elaboration time - before the Write_Letter_A_ -- To_Variable task starts to run), and remains '*'. Add the line of code -- in Access_Variable to continually read from the global 'Unprotected' -- variable. (Or replace 'PUT_LINE(Letter)' with 'PUT_LINE(Unprotected)') -- -- Ed -- with Text_IO; use Text_IO; procedure Unprotected_Shared_Variable is -- -- This is global to both tasks ... -- Unprotected : Character := '*'; pragma SHARED(Unprotected); task Write_Letter_A_To_Variable; task Access_Variable; task body Write_Letter_A_To_Variable is -- -- 'Letter' is local to this task -- Letter : constant Character := 'A'; begin loop -- -- And is stuck into the GLOBAL variable 'Unprotected' -- -- This part is correct . . . -- Unprotected := Letter; delay 0.5; end loop; end Write_Letter_A_To_Variable; task body Access_Variable is -- -- 'Letter' is local to this task . . . -- and is initialized at ELABORATION TIME. -- (That is, it's only written one time, and -- it gets written before the Write_Letter_A_To_Variable -- task starts to run, so it will always be '*' ). -- Letter : Character := Unprotected; begin loop -- -- Insert this line and it will work fine . . . -- Letter := Unprotected; Put (Letter); delay 3.0; end loop; end Access_Variable; begin null; end Unprotected_Shared_Variable; _________________________________________________________________________ -- Ed Costello -- Lawrence Livermore National Lab -- 1-415-422-1012