diff --git a/srp_analysis/src/main.rs b/srp_analysis/src/main.rs index 41e00db02c2698ec840651edca812d63266badd9..2ddefcaa2b592215c48a59cf6999710255e31901 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; }