* shared variable between tasks
@ 1989-06-29 2:07 Nicholas Tan Chee Hiang
1989-06-29 12:12 ` Mark D. Guzzi
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Tan Chee Hiang @ 1989-06-29 2:07 UTC (permalink / raw)
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: shared variable between tasks
1989-06-29 2:07 shared variable between tasks Nicholas Tan Chee Hiang
@ 1989-06-29 12:12 ` Mark D. Guzzi
0 siblings, 0 replies; 2+ messages in thread
From: Mark D. Guzzi @ 1989-06-29 12:12 UTC (permalink / raw)
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1989-06-29 12:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-06-29 2:07 shared variable between tasks Nicholas Tan Chee Hiang
1989-06-29 12:12 ` Mark D. Guzzi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox