diff --git a/examples/timing_exam.rs b/examples/timing_exam.rs index 682a9405569fccf6fa22749e187f3e3c33a96805..31ccb10663a691b49697f5168f93d5e495ef2910 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