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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,37f13de4a5a41a8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-31 12:16:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!freenix!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Elegant 'abort' of sleeping task Date: Mon, 31 Mar 2003 10:49:26 -0600 Organization: ENST, France Message-ID: References: <310b040f.0303310518.76dc9bf7@posting.google.com> Reply-To: "comp.lang.ada mail to news gateway" NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1049141736 63427 137.194.161.2 (31 Mar 2003 20:15:36 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 31 Mar 2003 20:15:36 +0000 (UTC) Cc: simon_the_softy@hotmail.com To: "comp.lang.ada mail to news gateway" Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:35836 Date: 2003-03-31T10:49:26-06:00 Hi Simon, I have a timer package that does what I believe you need. I do not have access to the code at the moment, but later today I will get it and post it on my FTP site. Basically, the package declares an abstract data type Timers, which has a discriminant specifying the maximum number of timeouts that can be simultaneously managed. Operations are provided for Setting and Clearing of timers. Individual timer members of the object are identified by a positive integer. Timers can be set either at a specified time from now, or at an absolute time. Internally, the object contains a time-ordered array of the timers' absolute expiration time, an access to the callback procedure to be called on expiration, and identification. When one of the operations is called, a persistent signal is sent to the timer manager task which aborts the current delay until statement, using asynchronous transfer of control. This the permits the ordered array to be manipulated as required by the operation, followed by the initiation of a new delay until statement for the earliest expiration time in the list. Upon timer expiration, a "callback" procedure is called, with the timer identification as its only parameter. The Set operation has a parameter to specify which Action procedure (callback) is to be called upon timer expiration. This package has been in heavy use since 1997. ----- Original Message ----- From: "Simon Apperley" Newsgroups: comp.lang.ada To: Sent: Monday, March 31, 2003 7:18 AM Subject: Elegant 'abort' of sleeping task > Hi, > > I'm looking at the design of a piece of server code which has to > handle calls that also pass a timeout value. The target system is > aerospace related, and dynamically creating tasks 'on the fly' just is > not an option. > > I want to be able to set up a single task to handle the timeout from > the head of a delta-queue of timeouts, but have found a problem. If I > have the timeout implemented as a task stuck in a 'delay' call, and a > more immediate timeout comes in, I want to wake up the sleeping task, > re-calculate the delta-queue and then sleep on the new, shorter, > delay. So far the only way I can see to do this is to use abort, and > set up the task again, which seems a bit of a brute force approach. > > Has anyone got any suggestions on how I can interrupt the sleep call, > without using a polling approach that would just consume CPU time at > the expense of the other code in the system. > > I could use direct calls to the underlying RTOS, but I'd rather keep > as much as possible within the Ada language. > > I did wonder about delay until TIME, and having another task change > TIME, but that seems rather un-safe to me as it starts making > assumptions about the underlying run-time implementation. > > Thanks > > Simon Apperley @ General Dynamics UK COM > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >