comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Watchdog-Timer Assignment
Date: Fri, 21 Sep 2018 20:29:53 -0700 (PDT)
Date: 2018-09-21T20:29:53-07:00	[thread overview]
Message-ID: <ccfc23e7-90f2-45c4-a01e-d5d33fdef55c@googlegroups.com> (raw)
In-Reply-To: <da1f586e-51e6-4e1d-9935-eabd7b12b484@googlegroups.com>

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.
> 
> You can find my code here: https://ideone.com/LIWmJM
> 
> My assignment is this:
> 
> Modify F3 from Part 1 so that it occasionally takes more than 0.5 seconds to execute.
> 
> 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.
> 
> The watchdog task should be started (released) at the same time as (or just before) F3 starts executing, and from that point measure the time that F3 uses.
> 
> When F3 misses its deadline the cyclic executive should re-synchronize so that F1 is started at whole seconds.
> 
> You should start with this skeleton code: part 2. Examine the code to understand how a task is declared inside an Ada program. Try to modify it in places indicated by the comments. You can also reuse your solution for part 1 as the initial code.
> 
> (P.S The skeleton code "part 2" is more or less an empty Watchdog task-body).
> 
> I have implemented a random delay for f3 so that it occasionally takes more 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 the next whole second.
> 
> I dont know where I should put that delay for this to happen.
> 
> 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  := Natural(Second);
	Rounded   : Constant Duration := Duration(Trunc);
	Year      : Year_Number;
	Month     : Month_Number;
	Day       : Day_Number;
	S         : Duration;
    Begin
	Split(
          Date    => Now,
          Year    => Year,
          Month   => Month,
          Day     => Day,
          Seconds => S
         );
	return Time_Of(Year, Month, Day,
	  (if Rounded < Second
	   then Rounded + 1.0
	   else Rounded
	  ));
    End Next_Second;


  parent reply	other threads:[~2018-09-22  3:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-21 10:29 Watchdog-Timer Assignment Alex
2018-09-21 22:35 ` Shark8
2018-09-21 23:13   ` Alex
2018-09-22  7:04     ` Simon Wright
2018-09-22 11:58       ` Alex
2018-09-22  2:34 ` Anh Vo
2018-09-22 11:54   ` Alex
2018-09-22 13:18     ` Dennis Lee Bieber
2018-09-25 17:05     ` Anh Vo
2018-09-22  3:29 ` Shark8 [this message]
2018-09-22 11:56   ` Alex
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox