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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a02:c49:: with SMTP id g70-v6mr400453jad.25.1537586994270; Fri, 21 Sep 2018 20:29:54 -0700 (PDT) X-Received: by 2002:a9d:6515:: with SMTP id i21-v6mr4707otl.0.1537586994191; Fri, 21 Sep 2018 20:29:54 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.216.MISMATCH!x81-v6no141268ita.0!news-out.google.com!c63-v6ni158ith.0!nntp.google.com!x81-v6no141267ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 21 Sep 2018 20:29:53 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=146.5.17.88; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.17.88 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Watchdog-Timer Assignment From: Shark8 Injection-Date: Sat, 22 Sep 2018 03:29:54 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:54402 Date: 2018-09-21T20:29:53-07:00 List-Id: On Friday, September 21, 2018 at 4:29:10 AM UTC-6, Alex wrote: > Hello, I have a school assignment (I have heard that this is important to= mention) which I need help with. >=20 > You can find my code here: https://ideone.com/LIWmJM >=20 > My assignment is this: >=20 > Modify F3 from Part 1 so that it occasionally takes more than 0.5 seconds= to execute. >=20 > Augment the cyclic scheduler from Part 1 with a watchdog task to monitor = F3's execution time. When F3 exceeds its deadline (0.5s), the watchdog task= should immediately print a warning message. I.e., 0.5s after start of F3, = either F3 has finished or the watchdog has printed a message. The watchdog = should let F3 finish even if it misses its deadline. >=20 > The watchdog task should be started (released) at the same time as (or ju= st before) F3 starts executing, and from that point measure the time that F= 3 uses. >=20 > When F3 misses its deadline the cyclic executive should re-synchronize so= that F1 is started at whole seconds. >=20 > You should start with this skeleton code: part 2. Examine the code to und= erstand how a task is declared inside an Ada program. Try to modify it in p= laces indicated by the comments. You can also reuse your solution for part = 1 as the initial code. >=20 > (P.S The skeleton code "part 2" is more or less an empty Watchdog task-bo= dy). >=20 > I have implemented a random delay for f3 so that it occasionally takes mo= re than 0.5 seconds to execute. My biggest issue (I believe) is that (if f3= takes more than 0.5 seconds to execute) f1 is supposed to start over at th= e next whole second. >=20 > I dont know where I should put that delay for this to happen. >=20 > Thank you in advance! This? Function Next_Second return Ada.Calendar.Time is Use Ada.Calendar; Now : Time renames Clock; Second : Duration renames Seconds(Now); Trunc : Constant Natural :=3D Natural(Second); Rounded : Constant Duration :=3D Duration(Trunc); Year : Year_Number; Month : Month_Number; Day : Day_Number; S : Duration; Begin Split( Date =3D> Now, Year =3D> Year, Month =3D> Month, Day =3D> Day, Seconds =3D> S ); return Time_Of(Year, Month, Day, (if Rounded < Second then Rounded + 1.0 else Rounded )); End Next_Second;