开发者

Can variable which is declared in same procedure body where tasks are be considered as shared for these tasks?

开发者 https://www.devze.com 2022-12-08 17:01 出处:网络
Variable is used in 1 task only, but the 开发者_如何学编程question is: can it be CALLED shared? I\'m assuming you\'re talking about a code structure something like this:

Variable is used in 1 task only, but the 开发者_如何学编程question is: can it be CALLED shared?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消