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 autolearn=ham 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 05:28:34 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: Elegant 'abort' of sleeping task Date: Mon, 31 Mar 2003 13:28:33 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <310b040f.0303310518.76dc9bf7@posting.google.com> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1049117313 4184 217.17.192.37 (31 Mar 2003 13:28:33 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Mon, 31 Mar 2003 13:28:33 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:35826 Date: 2003-03-31T13:28:33+00:00 List-Id: * Simon Apperley wrote: > 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. If you are not hiding your own process details, you can pass the timeout value down to the lowest level routines. Running on an approbriate OS, all syscalls has a separate timeout parameter, therefore you are done. ;-) > 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. Do not use delay: Use the syscall to sleep a specified amount of time or shorter if an event occur. In Posix enviroments, select(2) or poll(2) comes to mind. But if possible look for calls like epoll(2). > 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. Depends on your system. Most can do this easily. > I could use direct calls to the underlying RTOS, but I'd rather keep > as much as possible within the Ada language. Write a wrapper "procedure Pause_Max (seconds : in out Delay_T; events : out Event_Array; last_event : out Natural)" or "function Pause_Max (seconds : Delay_T) return event_or_remaining_time_t". > 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. This will not work, because it will not stop in the case of events.