From d7b02c2f22528c500131d43df38f654cde15cb8e Mon Sep 17 00:00:00 2001 From: Blinningjr <nicke.l@telia.com> Date: Sat, 2 Jan 2021 12:34:34 +0100 Subject: [PATCH] Implemented in interference time function --- srp_analysis/src/main.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/srp_analysis/src/main.rs b/srp_analysis/src/main.rs index 41e00db..2ddefca 100644 --- a/srp_analysis/src/main.rs +++ b/srp_analysis/src/main.rs @@ -76,6 +76,7 @@ fn main() { for t in &tasks { block_time(t, &tasks, &ip, &tr); + interference_time(t, &tasks); } } @@ -129,6 +130,7 @@ fn response_time(task: &Task) -> u32 { //let r: u32 = block_time(task) + wcet(task) + interference_time(task); //println!("response_time {:?}", r); //return r; + // TODO: Implement return 0; } @@ -206,10 +208,32 @@ fn block_time(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u3 /* * Calculates the interference (preemptions) to task t(I(t)). * I(t) + * + * Note: I(t) = sum(C(h) * ceiling(Bp(t)/A(h))), forall tasks h, P(h) > P(t), where + * Bp(t) is the busy-period */ -fn interference_time(task: &Task) -> u32 { -// TODO: Implement - return 0; +fn interference_time(task: &Task, tasks: &Tasks) -> u32 { + let mut interference: u32 = 0; + for t in tasks { + if t.prio > task.prio { + interference += wcet(&t.trace) * (((busy_period(t) as f32) / (t.inter_arrival as f32)).ceil() as u32); + } + } + + println!("interference_time {:?}", interference); + return interference; +} + + +/* + * Caclulates the busy period of task t(Bp(t)). + * Bp(t) + * + * Note: We can over approximate the busy period Bp(i) = D(i) (assuming the worst allowed busy-period). + * D(i) is the deadline of task i. + */ +fn busy_period(task: &Task) -> u32 { + return task.deadline; } -- GitLab