Skip to content
Snippets Groups Projects
Commit e9ae2680 authored by Ruben Asplund's avatar Ruben Asplund
Browse files

Small changes to blocking()

parent c0eee49c
Branches
No related tags found
No related merge requests found
...@@ -174,9 +174,7 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32 ...@@ -174,9 +174,7 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32
lower_prio_tasks.remove(&t.id); lower_prio_tasks.remove(&t.id);
} }
} }
// println!("{:?}", lower_prio_tasks);
if lower_prio_tasks.len() == 0 { if lower_prio_tasks.len() == 0 {
// println!("0");
return 0; return 0;
} }
/* Finding longest blocking */ /* Finding longest blocking */
...@@ -186,13 +184,11 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32 ...@@ -186,13 +184,11 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32
let mut current_block = 0; let mut current_block = 0;
// Iterate through current task resources // Iterate through current task resources
for r1 in resources { for r1 in resources {
// println!("Resource 1: {}, Resources 1 {:?}", r1, resources);
// Iterate through lower prio tasks // Iterate through lower prio tasks
for t_id in &lower_prio_tasks { for t_id in &lower_prio_tasks {
let mut lower_prio_task_resources = &tr[t_id]; let mut lower_prio_task_resources = &tr[t_id];
// Iterate through lower prio task resources // Iterate through lower prio task resources
for r2 in lower_prio_task_resources { for r2 in lower_prio_task_resources {
// println!("Resource 2: {}, Resources 2 {:?}", r2, lower_prio_task_resources);
// When current task use the same resource as a task // When current task use the same resource as a task
if r1 == r2 { if r1 == r2 {
// Takes forward the blocking task // Takes forward the blocking task
...@@ -205,8 +201,6 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32 ...@@ -205,8 +201,6 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32
if max_block < current_block { if max_block < current_block {
max_block = current_block; max_block = current_block;
} }
// println!("1: start:{}, end:{}", inner.start, inner.end);
// println!("For id {} and resource 2 {}", t_id, r2)
} }
// Iterate through second layer // Iterate through second layer
for inner2 in &inner.inner { for inner2 in &inner.inner {
...@@ -215,8 +209,13 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32 ...@@ -215,8 +209,13 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32
if max_block < current_block { if max_block < current_block {
max_block = current_block; max_block = current_block;
} }
// println!("2: start:{}, end:{}", inner2.start, inner2.end); }
// println!("For id {} and resource 2 {}", t_id, r2) // Iterate through third layer
for inner3 in &inner2.inner {
current_block = inner2.end.wrapping_sub(inner2.start);
if max_block < current_block {
max_block = current_block;
}
} }
} }
} }
...@@ -226,6 +225,5 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32 ...@@ -226,6 +225,5 @@ fn blocking(task: &Task, tasks: &Tasks, ip: &IdPrio, tr: &TaskResources) -> u32
} }
} }
} }
// println!("{}", max_block);
return max_block; return max_block;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment