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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2ead6cfaad7d134b X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: scheduler program in Ada Date: 1998/06/06 Message-ID: #1/1 X-Deja-AN: 360125199 References: <6la99o$jcu@lotho.delphi.com> Mail-Copies-To: sam@ada.eu.org Content-Type: text/plain; charset=US-ASCII Organization: TELECOM Paris Mime-Version: 1.0 (generated by tm-edit 7.108) Newsgroups: comp.lang.ada Date: 1998-06-06T00:00:00+00:00 List-Id: >>>>> "T" == tmoran writes: T> Will something along these lines do what you want? T> start_time : ada.calendar.time := ada.calendar.clock; T> now: duration := 0; -- duration since start_time T> begin T> open the todo file containing records with (offset, job) T> loop T> read next todo record T> if todo.offset > now then T> delay todo.offset-now; T> now := ada.calendar.clock - start_time; T> end if; T> start todo.job T> end loop; This is a typical situation where "delay until" is much more useful than "delay" for two reasons: 1) You compute "now", then do a test, then sleep for "todo.offset - now". This means that "now" is no longer accurate (if your system is damn slow) at the time of substraction. 2) If you have other tasks and get preempted just before the delay, you will sleep for too long a time. The following scheme should be better: loop read next todo record delay until todo.offset + start_time start todo.job end loop It also makes the test unnecessary, since if "todo.offset + start_time" is before the current time, the "delay until" will have no effect. Sam -- Samuel Tardieu -- sam@ada.eu.org