From 50dbe97eae728c4ade573fd4eb14968579d3a228 Mon Sep 17 00:00:00 2001
From: Blinningjr <nicke.l@telia.com>
Date: Mon, 11 Jan 2021 15:13:52 +0100
Subject: [PATCH] Fixed my answere for question 2 in timing_exam

---
 examples/timing_exam.rs | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/examples/timing_exam.rs b/examples/timing_exam.rs
index 682a940..31ccb10 100644
--- a/examples/timing_exam.rs
+++ b/examples/timing_exam.rs
@@ -176,8 +176,11 @@ const APP: () = {
 // `cx.schedule.t1(cx.scheduled + 100_000.cycles()).unwrap();`
 //
 // [Your answer here]
-// Instant::now() may have drift/jitter, meaning that it is not completely accurate.
-// cx.scheduled has zero drift/jitter, thus it is accurate.
+// The main difference is that `Instant::now()` returns the current time in cycles and
+// `cx.scheduled` returns the time the task is scheduled for in cycles.
+//
+// Another difference is that `Instant::now()` may have drift/jitter, meaning that it is not completely accurate. 
+// `cx.scheduled` has zero drift/jitter, thus it is accurate.
 //
 //
 // Source: https://rtic.rs/0.5/book/en/by-example/timer-queue.html
@@ -187,9 +190,13 @@ const APP: () = {
 // in order to generate a periodic task.
 //
 // [Your answer here]
-// If we would use Instant::now() the timing of the periodic tasks would be a little inaccurate
-// because Instant::now() has a little drift/jitter. cx.scheduled has zero drift/jitter and thus
-// will have accurate timing of the periodic tasks.
+// The main reason is that `Instant::now()` returns the current time which will not be equal to the
+// start time of the task if the task is preempted by other tasks. But `cx.scheduled` returns the
+// scheduled time of the task thus it will always return the correct value, even if the task is
+// preempted.
+//
+// Another reason is that `Instant:now()` has some drift/jitter which causes the timing of the periods to be inaccurate.
+// But `cx.scheduled` has zero drift/jitter, thus making it better.
 //
 //
 // Hint, look at https://rtic.rs/0.5/book/en/by-example/timer-queue.html
-- 
GitLab