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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e2a9ad4da0a64a87 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newspeer.monmouth.com!uvsq.fr!freenix!news.enst.fr!news.rfc1149.net!not-for-mail From: "Vo, Anh \(US SSA\)" Newsgroups: comp.lang.ada Subject: RE: RE: Timing events in GNAT GPL 2006 Date: Mon, 15 Jan 2007 08:29:46 -0800 Organization: ENST, France Message-ID: References: <20070114131026.92190@gmx.net> NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: avanie.enst.fr 1168878627 95785 137.194.161.2 (15 Jan 2007 16:30:27 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 15 Jan 2007 16:30:27 +0000 (UTC) To: "Rolf Ebert" , Return-Path: x-mimeole: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message In-Reply-To: <20070114131026.92190@gmx.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: RE: Timing events in GNAT GPL 2006 Thread-Index: Acc33V3l0QyR4sBIRpSn1/LbB/hUZgA4yHww X-OriginalArrivalTime: 15 Jan 2007 16:29:46.0934 (UTC) FILETIME=[5ED77D60:01C738C2] X-Virus-Scanned: amavisd-new at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.9rc1 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , X-Leafnode-NNTP-Posting-Host: 88.191.17.134 Xref: g2news2.google.com comp.lang.ada:8137 Date: 2007-01-15T08:29:46-08:00 -----Original Message----- From: Rolf Ebert [mailto:rolf.ebert_nospam_@gmx.net]=20 Sent: Sunday, January 14, 2007 5:10 AM To: Vo, Anh (US SSA); comp.lang.ada@ada-france.org Subject: Re: RE: Timing events in GNAT GPL 2006 << > There are three things wrong with your codes. Two of them are critical. > 1. The protected procedure Inc_Clock has wrong parameter mode. It must > be in out mode. > 2. The call Set_Handler from the protected procedure will result in a > deadlock it is run. > 3. Protected object must be declared at the library level. Yours is not. > As the result, non-local pointer cannot point to local object error at > lines 20 and 26 OK, I fixed issues 1 and 3 in my code and I can observe issue 2. I don't understand, however, why the deadlock occurs. Is the deadlock required by the RM or is it just due to GNAT's implementation of Timing_Events? >> This deadlock occurred when I tested it. I was supposed to find out why? But, I have not had a chance to investigate it yet. =20 << > I designed for both one shot and periodic timers using Timing Event. If > it is helpful, I will post my code here. Just let me know. Although I found by now your discussion from around March 2006, I'd like to see your code. >> To break the deadlock above, I have to uncouple the action of Event Handler and Set Handler as shown in the Generic_Timers package. with Ada.Real_Time.Timing_Events; generic One_Shot : Boolean :=3D True; Timer_Name : String :=3D "Generic_Timers"; For_Duration : in Ada.Real_Time.Time_Span; with procedure Action is <>; package Generic_Timers is Timer_Error : exception; procedure Start; procedure Stop; procedure Cancel; private The_Event : Ada.Real_Time.Timing_Events.Timing_Event; end Generic_Timers; package body Generic_Timers is use Ada; task Event_Handoff is entry Handoff; end Event_Handoff; task body Event_Handoff is begin Longlive : loop select accept Handoff; delay 0.0; -- make sure protected operation is completed before Start; -- starting the next cycle. or terminate; -- later alligator end select; end loop Longlive; end Event_Handoff; protected Events is procedure Handler (Event: in out Real_Time.Timing_Events.Timing_Event); end Events; protected body Events is procedure Handler (Event: in out Real_Time.Timing_Events.Timing_Event) is begin Action; Pragma Warnings (Off); if not One_Shot then Event_Handoff.Handoff; end if; Pragma Warnings (On); end Handler; end Events; procedure Start is use type Ada.Real_Time.Timing_Events.Timing_Event_Handler; begin if Real_Time.Timing_Events.Current_Handler (The_Event) =3D null = then Real_Time.Timing_Events.Set_Handler ( The_Event, For_Duration, Events.Handler'access); else raise Timer_Error with Timer_Name & " started already"; end if; end Start; procedure Stop is Success : Boolean :=3D False; use type Ada.Real_Time.Timing_Events.Timing_Event_Handler; begin if Real_Time.Timing_Events.Current_Handler (The_Event) /=3D null then Real_Time.Timing_Events.Cancel_Handler (The_Event, Success); if not Success then raise Timer_Error with "fail to cancel " & Timer_Name; end if; end if; end Stop; procedure Cancel renames Stop; end Generic_Timers; << Thanks for your fast response >> You are welcome. AV