Skip to content
Snippets Groups Projects
Commit 97a20365 authored by Blinningjr's avatar Blinningjr
Browse files

Finished total load factor function

parent 3c1b0f88
No related branches found
No related tags found
No related merge requests found
......@@ -68,9 +68,44 @@ fn main() {
let tasks: Tasks = vec![t1, t2, t3];
println!("tasks {:?}", &tasks);
// println!("tot_util {}", tot_util(&tasks));
println!("tot_util {}", total_load_factor(&tasks));
let (ip, tr) = pre_analysis(&tasks);
println!("ip: {:?}", ip);
println!("tr: {:?}", tr);
}
/*
* Calculates the total load factor(Ltot).
*
* Note: We can compute the total CPU request (or load factor), as Ltot = sum(L(T)), T being the set of tasks.
*/
fn total_load_factor(tasks: &Tasks) -> f32 {
let mut ltot: f32 = 0.0;
for t in tasks {
ltot += cpu_load(t);
}
return ltot;
}
/*
* Calculates the cpu load of a task(L(t) where t is a task).
*
* 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)?
*/
fn cpu_load(task: &Task) -> f32 {
return (wcet(task) as f32) / (task.inter_arrival as f32)
}
/*
* Worst case execution time(WCET) of a task t(C(t)).
*/
fn wcet(task: &Task) -> u32 {
// TODO: Check if this is correct.
return task.trace.end.wrapping_sub(task.trace.start);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment