Skip to content
Snippets Groups Projects
Commit 7aeeb35f authored by Edvin Åkerfeldt's avatar Edvin Åkerfeldt
Browse files

Part 2 done, now break instead of panic

parent 567e81f5
No related branches found
No related tags found
No related merge requests found
......@@ -47,13 +47,13 @@ const APP: () = {
// emulates timing behavior of t1
cortex_m::asm::delay(10_000);
asm::bkpt();
// 2) your code here to update T1_MAX_RP and
// break if deadline missed
let resp: u32= start.elapsed().as_cycles();
if resp > 100_000 {
panic!();
//panic!();
asm::bkpt();
} else {
unsafe {
if resp > T1_MAX_RP {
......@@ -74,7 +74,6 @@ const APP: () = {
asm::bkpt();
// 1) your code here to emulate timing behavior of t2
asm::bkpt();
// == Begin trace ==
asm::delay(10_000);
......@@ -94,13 +93,12 @@ const APP: () = {
asm::delay(2_000);
// == End trace ==
asm::bkpt();
// 2) your code here to update T2_MAX_RP and
// break if deadline missed
let resp: u32= start.elapsed().as_cycles();
if resp > 200_000 {
panic!();
//panic!();
asm::bkpt();
} else {
unsafe {
if resp > T2_MAX_RP {
......@@ -120,7 +118,6 @@ const APP: () = {
asm::bkpt();
// 1) your code here to emulate timing behavior of t3
asm::bkpt();
// == Begin trace ==
asm::delay(10_000);
......@@ -134,7 +131,8 @@ const APP: () = {
// break if deadline missed
let resp: u32= start.elapsed().as_cycles();
if resp > 50_000 {
panic!();
//panic!();
asm::bkpt();
} else {
unsafe {
if resp > T3_MAX_RP {
......@@ -184,6 +182,12 @@ const APP: () = {
// `cx.schedule.t1(cx.scheduled + 100_000.cycles()).unwrap();`
//
// [Your answer here]
/*
Instant is a struct that can contain cycle count from the DWT.
Instant::now() gives you the current value of the counter for example.
The schedule function above fetches the time when the task was spose to run (cx.scheduled) and increments it by the inter_arrival.
This further means that the schedule will never be ofset even if the task is blocked before starting.
*/
//
// Explain in your own words the difference between:
//
......@@ -192,11 +196,20 @@ const APP: () = {
// `cx.schedule.t1(cx.scheduled + 100_000.cycles()).unwrap();`
//
// [Your answer here]
/*
Using Instant::now() would schedual the next task from the point the task starts excecuting (after being blocked) and this would push the excection of the next task iteration further and further each time it executes.
Using cx.scheduled would schedual the next iteration from the time the task was last scheduled. This will not push the exection of the next iteration.
*/
//
// Explain in your own words why we use the latter
// in order to generate a periodic task.
//
// [Your answer here]
/*
See above, but tldr;
The first one would push the arrivaltime of the task each time it is scheduled, while the later will give use the same inter_arrival time every time.
*/
//
// Hint, look at https://rtic.rs/0.5/book/en/by-example/timer-queue.html
//
......@@ -217,6 +230,9 @@ const APP: () = {
// Explain why this is needed (there is a good reason for it).
//
// [Your answer here]
/*
Because multiple tasks can access these variables, rust can't ensure that the read is safe to do.
*/
//
// Implement this functionality for all tasks.
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment