This commit is contained in:
Rushil Umaretiya 2024-04-18 03:24:34 -04:00
parent e00d6cab27
commit 834d2f876b
No known key found for this signature in database
GPG Key ID: 4E8FAF9C926AF959

View File

@ -44,20 +44,18 @@ void priority_queue(unsigned int quantum) {
if (task->remaining_cycles != 0) {
append_task(task->pid, task->priority, task->remaining_cycles);
}
if (size() > 1)
min_heapify();
}
}
void round_robin(unsigned int quantum) {
while (size() > 0) {
for (unsigned int i = 0; i < size(); i++) {
task_struct* task = get_task(i % size());
run_with_quantum(task, quantum);
if (task->remaining_cycles == 0) {
remove_task(task->pid);
}
int i = 0;
while (size() > 0)
{
task_struct *task = get_task(i % size());
run_with_quantum(task, quantum);
if (task->remaining_cycles == 0) {
remove_task(task->pid);
}
i++;
}
}