views:

40

answers:

1

Variable is used in 1 task only, but the question is: can it be CALLED shared?

+1  A: 

I'm assuming you're talking about a code structure something like this:

procedure A_Procedure_Body is  

   task T1 is
      entry T1_E1;
   end T1;  

   task T2 is
      entry T2_E1;
   end T2;  

   Some_Variable : Integer;  

   task body T1 is
      T1_Local : Integer;
   begin
      T1_Local := Some_Variable;
       ...
   end T1;  

   task body T2 is
      T2_Local : Integer := 42;
   begin
      Some_Variable := T2_Local;
      ...
   end T2;  

begin
   null;
end A_Procedure_Body;

In this case "Some_Variable" is global to both tasks, but not shared in the Ada sense of being properly protected for consistent, concurrent access.

Even if the global variable is actually referenced by only one of the tasks, and so there's no chance of any concurrency-initiated problems occurring while accessing it, it still doesn't make the variable shared.

Marc C