comp.lang.ada
 help / color / mirror / Atom feed
From: "Rego, P." <pvrego@gmail.com>
Subject: Synchronization: delays x hardware timers
Date: Fri, 26 Apr 2013 08:27:39 -0700 (PDT)
Date: 2013-04-26T08:27:39-07:00	[thread overview]
Message-ID: <dd7bbc1b-75ac-480a-af74-a7db7c007d98@googlegroups.com> (raw)

Dear friends,

I would very appreciate your opinions about synchronization. I have a global (static) variable which is send periodically over the communication media and a flag is checked each cycle to get the equipment response about that sent message. In this case, two different flags must be sent in order to have the correct response.

So I have an asynchronous call to a procedure Request_Action:

Global_Flag := Flag_Type; -- This is sent periodically.
procedure Request_Action is
   Initial_Response : Response_Type := Get_Response; -- which is /= NULL_RESPONSE
   Updated_Response : Response_Type := NULL_RESPONSE; -- NULL_RESPONSE is constant
   
   while Updated_Response < Initial_Response loop
      Global_Flag := FIRST_FLAG; -- Now I should wait for the response to be ready
      <Process_Wait>;
      Global_Flag := SECOND_FLAG; -- Now I should wait again.
      <Process_Wait>;

      Updated_Response := Get_Response;
   end loop;
end Request_Action;

The question is which is the best way to implement the <Process_Wait>. The application is soft real-time and I just need to ensure that Global_Flag to be processed before the next cycle begins. Also, I need to use only Ada 95.

I think that if I use a simple delay it's very enough; and since I do not have a hard real-time deadline, I even do not need to use delay until. A coleague argued with me saying that I must use hardware timers any case. Personally I think it's an unnecessary use of hardware resources.

I would simply code this as 
   delay CYCLE_TASK + CYCLE_DELTA;

Thus, what is your opinion?

Thanks very much.



             reply	other threads:[~2013-04-26 15:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26 15:27 Rego, P. [this message]
2013-04-26 16:03 ` Synchronization: delays x hardware timers Dmitry A. Kazakov
2013-04-26 17:22 ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox