From 5f5852eec564d65bcdc20100838b3d1f483efb39 Mon Sep 17 00:00:00 2001
From: Blinningjr <nicke.l@telia.com>
Date: Sat, 2 Jan 2021 12:57:24 +0100
Subject: [PATCH] Made a analyse function

---
 srp_analysis/src/common.rs |  5 ++---
 srp_analysis/src/main.rs   | 23 ++++++++++++++++++++---
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/srp_analysis/src/common.rs b/srp_analysis/src/common.rs
index d6f92b1..48cebac 100644
--- a/srp_analysis/src/common.rs
+++ b/srp_analysis/src/common.rs
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
 
 // common data structures
 
-#[derive(Debug)]
+#[derive(Debug, Clone)]
 pub struct Task {
     pub id: String,
     pub prio: u8,
@@ -11,8 +11,7 @@ pub struct Task {
     pub trace: Trace,
 }
 
-//#[derive(Debug, Clone)]
-#[derive(Debug)]
+#[derive(Debug, Clone)]
 pub struct Trace {
     pub id: String,
     pub start: u32,
diff --git a/srp_analysis/src/main.rs b/srp_analysis/src/main.rs
index 03bb377..8ba2019 100644
--- a/srp_analysis/src/main.rs
+++ b/srp_analysis/src/main.rs
@@ -74,9 +74,8 @@ fn main() {
     println!("ip: {:?}", ip);
     println!("tr: {:?}", tr);
 
-    for t in &tasks {
-        response_time(t, &tasks, &ip, &tr);
-    }
+    let analysis = analyse(&tasks, &ip, &tr);
+    println!("Analysis {:#?}", analysis);
 }
 
 
@@ -234,3 +233,21 @@ fn busy_period(task: &Task) -> u32 {
 }
 
 
+/*
+ * Analyse tasks.
+ *
+ * Note: Finally, make a function that iterates over the task set and returns a vector with containing:
+Vec<Task, R(t), C(t), B(t), I(t)>. Just a simple println! of that vector gives the essential information on the analysis.
+ */
+fn analyse(tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> Vec<(Task, u32, u32, u32, u32)> {
+    let mut analysis: Vec<(Task, u32, u32, u32, u32)> = vec!();
+    for t in tasks {
+        let r_t = response_time(t, tasks, ip, tr);
+        let c_t = wcet(&t.trace);
+        let b_t = block_time(t, tasks, ip, tr);
+        let i_t = interference_time(t, tasks);
+        analysis.push((t.clone(), r_t, c_t, b_t, i_t));
+    }
+    return analysis;
+}
+
-- 
GitLab