review
I think you need to make wcet end - start as it does not always start at 0.
In preemptions it should be I(t) = sum(C(h) * ceiling(Bp(t)/A(h)) but it looks like you do I(t) = sum(C(t) * ceiling(Bp(t)/A(h)) wcet should be from t and not task.
After changing that, we got the same results.
I have not done it myself yet, but other reviewers and friends told me a low priority task can block a middle priority task without it sharing resources, if a higher priority task uses the same resource as the low priority one. I tried making a test for that:
#[test]
fn test_blocking_reverse() {
let t1 = Task {
id: "T1".to_string(),
prio: 1,
deadline: 100,
inter_arrival: 100,
trace: Trace {
id: "T1".to_string(),
start: 0,
end: 10,
inner: vec![Trace {
id: "R2".to_string(),
start: 2,
end: 8,
inner: vec![],
}], },
};
// Task T2
// Middle priority
// Two traces
let t2 = Task {
id: "T2".to_string(),
prio: 2,
deadline: 200,
inter_arrival: 200,
trace: Trace {
id: "T2".to_string(),
start: 0,
end: 30,
inner: vec![
Trace {
id: "R1".to_string(),
start: 10,
end: 20,
inner: vec![],
},
],
},
};
// Task T3
let t3 = Task {
id: "T3".to_string(),
prio: 3,
deadline: 50,
inter_arrival: 50,
trace: Trace {
id: "T3".to_string(),
start: 0,
end: 30,
inner: vec![Trace {
id: "R2".to_string(),
start: 10,
end: 20,
inner: vec![],
}],
},
};
let tasks = vec![t1, t2, t3];
let block_1 = tasks[0].block_time(&tasks);
let block_2 = tasks[1].block_time(&tasks);
let block_3 = tasks[2].block_time(&tasks);
assert_eq!(block_1, 0);
assert_eq!(block_2, 6);
assert_eq!(block_3, 6);
}
I got 0,0,6 on your code.