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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8da181ade72859cf X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!attbi_s53.POSTED!53ab2750!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: Subject: Re: timeouts X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: <2jVUc.13319$Fg5.12445@attbi_s53> NNTP-Posting-Host: 24.21.42.251 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s53 1092886846 24.21.42.251 (Thu, 19 Aug 2004 03:40:46 GMT) NNTP-Posting-Date: Thu, 19 Aug 2004 03:40:46 GMT Organization: Comcast Online Date: Thu, 19 Aug 2004 03:40:46 GMT Xref: g2news1.google.com comp.lang.ada:2831 Date: 2004-08-19T03:40:46+00:00 List-Id: What version of GNAT? I vaguely recall a gnat bug having to do with time. Unfortunately I can't recall the particulars. Maybe someone else on the list will remember. Steve (The Duck) "Brian May" wrote in message news:sa4smakuhzq.fsf@snoopy.apana.org.au... > Hello, > > I have a written a communications protocols, for Windows, in Ada, > using the GNAT compiler for Windows. This is my attempt at > implementing the MAP27 protocol (used for talking to trunk radios). > > The main protocol is implemented as a separate task along the lines of > the following code. This code is simplified from my actual code, and > only shows the what I consider relevant to this bug, based on print > messages. Any mistakes in syntax are probably copy errors. > > I should be able to provide full code on request, but need to confirm > this first. > > task body State_Machine_Task is > timer_enabled : Boolean := True; > expire_time : Duration := clock + 0.1; > ... > begin > ... > Put(Log.Debug,"----------------------------------------"); > Put(...); > Put(timer_enabled,expire_time); > Put(...); > > while Continue loop > case SMT.DTE_State is > when ... => > select > accept ... > ... > or > ... > or > when timer_enabled => > delay until expire_time; > > print ("In.Link_Establishment_Timeout"); > > expire_time := clock + 0.1; > end select; > > when ... => > ... > > ... > > end case; > end loop; > end; > > > Generally speaking, the program does all this fine, and constantly > prints the expired message, as required. > > However, occasionally something goes wrong, and while it prints the > expiration time OK, it takes ages to print the "expired" > message. e.g. one occasion the event was 7 hours late. This puzzles > me, because every time the timer is incremented by 0.1 seconds, and my > understanding is that the timer should trigger if the current time is > greater then the expiration time. > > To be precise, at 1:50:57 am the timer was incremented, and the select > reentered, and at 9:12:59 the timer expired. The actual log produced > is below: > > 1:50:57 DLL DEBUG Activity_Timer: disabled > 1:50:57 DLL DEBUG Link_Failure_Detection_Timer: disabled > 1:50:56 DLL DEBUG In.Link_Establishment_Timeout > 1:50:56 DLL DEBUG Out.Link_Request( 14, 1, 1) > 1:50:56 T50 DEBUG TX Packet Packet( 22 16 2 1 14 1 1 16 3 138 9 ) > 1:50:57 DLL DEBUG Out.Link_Request return > 1:50:57 DLL DEBUG ---------------------------------------- > 1:50:57 DLL DEBUG looping state=RESET_WAIT > 1:50:57 DLL DEBUG Link_Establishment_Timer time 1:50:57 > 1:50:57 DLL DEBUG Retry_Timer: disabled > 1:50:57 DLL DEBUG Acknowledgement_Timer: disabled > 1:50:57 DLL DEBUG Activity_Timer: disabled > 1:50:57 DLL DEBUG Link_Failure_Detection_Timer: disabled > 9:12:59 DLL DEBUG In.Link_Establishment_Timeout > 9:12:59 DLL DEBUG Out.Link_Request( 14, 1, 1) > 9:12:59 T50 DEBUG TX Packet Packet( 22 16 2 1 14 1 1 16 3 138 9 ) > 9:12:59 DLL DEBUG Out.Link_Request return > 9:12:59 DLL DEBUG ---------------------------------------- > 9:12:59 DLL DEBUG looping state=RESET_WAIT > 9:12:59 DLL DEBUG Link_Establishment_Timer time 9:12:59 > 9:12:59 DLL DEBUG Retry_Timer: disabled > 9:12:59 DLL DEBUG Acknowledgement_Timer: disabled > 9:12:59 DLL DEBUG Activity_Timer: disabled > 9:12:59 DLL DEBUG Link_Failure_Detection_Timer: disabled > > The fact that the time decrements from 57 seconds to 56 seconds seems > weird in itself. It could be due to some obscure round of error in my > code to print the time, but I can't imagine where this would occur. In > all cases the current value of Clock is used, and it isn't stored > anywhere. Or it could be some sort of time synchronisation tool on the > computer, I am not aware of anything like this though. > > During this wait, all evidence points to the fact that the > timer_enabled and expire_time variables are correct, they cannot be > changed from other tasks, and that it was waiting in the select > statement. During this time, the task appears to respond to other > select events fine. I haven't yet tested if the timeout starts working > again after entering the select again, as the structure of the code > doesn't make this easy. > > What is going on? Strict real-time behaviour is not required, but 7 > hours instead of 0.1 seconds is slightly on the extreme side. > > > Any ideas? > Thanks in advance. > > > PS. In hindsight, the "timer_enabled" variable may not be required, as > I can use the state variable instead and probably simplify some of the > code, but I am skeptical this is causing the problem. > -- > Brian May