diff --git a/srp_analysis/src/main.rs b/srp_analysis/src/main.rs index 9246224a27fe825280ab2ab7e23004903f023b37..bc088d42b3254265474f3c5b6b5d0b5e9f903003 100644 --- a/srp_analysis/src/main.rs +++ b/srp_analysis/src/main.rs @@ -73,11 +73,16 @@ fn main() { let (ip, tr) = pre_analysis(&tasks); println!("ip: {:?}", ip); println!("tr: {:?}", tr); + + for t in &tasks { + block_time(t, &tasks, &ip, &tr); + } } /* * Calculates the total load factor(Ltot). + * Ltot * * Note: We can compute the total CPU request (or load factor), as Ltot = sum(L(T)), T being the set of tasks. */ @@ -92,8 +97,11 @@ fn total_load_factor(tasks: &Tasks) -> f32 { /* * Calculates the cpu load of a task(L(t) where t is a task). + * L(t) * - * Note: Each task t has a WCET C(t) and given (assumed) inter-arrival time A(t). The CPU request (or load) inferred by a task is L(t) = C(t)/A(t). Ask yourself, what is the consequence of C(t) > A(t)? + * Note: Each task t has a WCET C(t) and given (assumed) inter-arrival time A(t). The CPU request (or load) inferred by a task is L(t) = C(t)/A(t). Ask yourself, what is the consequence of C(t) > A(t)? + * Answer: If C(t) > A(t) then the cpu load of task t is more then the available cpu power in the + * worst case. And the task t will not be able to finish in time in the worst case. */ fn cpu_load(task: &Task) -> f32 { return (wcet(task) as f32) / (task.inter_arrival as f32) @@ -102,10 +110,80 @@ fn cpu_load(task: &Task) -> f32 { /* * Worst case execution time(WCET) of a task t(C(t)). + * C(t) */ fn wcet(task: &Task) -> u32 { - // TODO: Check if this is correct. return task.trace.end.wrapping_sub(task.trace.start); } +/* + * Calculates the response time of task(R(t)). + * R(t) + * + * Note: * R(t) = B(t) + C(t) + I(t), where + * - B(t) is the blocking time for task t, and + * - I(t) is the interference (preemptions) to task t + */ +fn response_time(task: &Task) -> u32 { + //let r: u32 = block_time(task) + wcet(task) + interference_time(task); + //println!("response_time {:?}", r); + //return r; + return 0; +} + + +/* + * Calculates the blocking time for task t(B(t)). + * B(t) + * + * Note: B(t) = max(C(l_r)), where P(l) < P(t), π(l_r) >= P(t) + */ +fn block_time(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32 { + // Find all lower priority tasks + let mut lower_prio: Vec<&Task> = vec!(); + for t in tasks { + if t.prio < task.prio { + lower_prio.push(t); + } + } + + println!("prio {:?}", task.prio); + println!("lower_prio {:?}", lower_prio); + + // Find all resources that will block the task(resources with a higher of equal priority) from + // the resources that the lower priority tasks use. + let mut block_res: Vec<String> = vec!(); + for lpt in lower_prio { + match tr.get(&lpt.id) { + Some(resources) =>{ + for r in resources { + if *ip.get(r).unwrap() >= task.prio { + block_res.push(r.clone()); + } + } + }, + None => (), + }; + } + + println!("block_res {:?}", block_res); + + let mut wcets: Vec<u32> = vec!(); + + +// TODO: Implement + return 0; +} + + +/* + * Calculates the interference (preemptions) to task t(I(t)). + * I(t) + */ +fn interference_time(task: &Task) -> u32 { +// TODO: Implement + return 0; +} + +