mirror of
https://github.com/Comp211-SP24/lab-06-Rushilwiz.git
synced 2025-04-09 22:40:15 -04:00
clang formatted
This commit is contained in:
parent
c42a9b4418
commit
d62a046f5c
22
task.c
22
task.c
|
@ -177,26 +177,29 @@ void heapify(int i) {
|
||||||
while (!done && (2 * k + 1) < size()) {
|
while (!done && (2 * k + 1) < size()) {
|
||||||
int j = 2 * k + 1;
|
int j = 2 * k + 1;
|
||||||
|
|
||||||
|
|
||||||
if (j + 1 < size()) {
|
if (j + 1 < size()) {
|
||||||
// two children
|
// two children
|
||||||
|
|
||||||
task_struct *left = get_task(j);
|
task_struct* left = get_task(j);
|
||||||
task_struct *right = get_task(j + 1);
|
task_struct* right = get_task(j + 1);
|
||||||
|
|
||||||
float left_ratio = (float)left->priority / (float)left->remaining_cycles;
|
float left_ratio =
|
||||||
float right_ratio = (float)right->priority / (float)right->remaining_cycles;
|
(float)left->priority / (float)left->remaining_cycles;
|
||||||
|
float right_ratio =
|
||||||
|
(float)right->priority / (float)right->remaining_cycles;
|
||||||
|
|
||||||
if (right_ratio < left_ratio) {
|
if (right_ratio < left_ratio) {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task_struct *curr = get_task(k);
|
task_struct* curr = get_task(k);
|
||||||
task_struct *next = get_task(j);
|
task_struct* next = get_task(j);
|
||||||
|
|
||||||
float curr_ratio = (float)curr->priority / (float)curr->remaining_cycles;
|
float curr_ratio =
|
||||||
float next_ratio = (float)next->priority / (float)next->remaining_cycles;
|
(float)curr->priority / (float)curr->remaining_cycles;
|
||||||
|
float next_ratio =
|
||||||
|
(float)next->priority / (float)next->remaining_cycles;
|
||||||
|
|
||||||
if (curr_ratio > next_ratio) {
|
if (curr_ratio > next_ratio) {
|
||||||
swap(curr->pid, next->pid);
|
swap(curr->pid, next->pid);
|
||||||
|
@ -213,7 +216,6 @@ void min_heapify() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void print_tasks() {
|
void print_tasks() {
|
||||||
// DO NOT MODIFY
|
// DO NOT MODIFY
|
||||||
task_struct* p_task = head;
|
task_struct* p_task = head;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user