void schedule()
{
Task *current;
// print task list (sanity checker)
traverse(head);
current = pickNextTask();
run(current, current->burst);
delete(&head, current);
}
Task *pickNextTask()
{
return head->task;
}
void schedule()
{
Task* current;
// print task list (sanity checker)
traverse(head);
current = pickNextTask();
run(current, current->burst);
delete(&head, current);
}
Task* pickNextTask()
{
int min_burst = 9999;
struct node* cur_node = head;
struct node* min_node = head;
while (cur_node != NULL) {
if (cur_node->task->burst < min_burst) {
min_burst = cur_node->task->burst;
min_node = cur_node;
}
cur_node = cur_node->next;
}
return min_node->task;
}
void schedule()
{
Task* current;
// print task list (sanity checker)
traverse(head);
current = pickNextTask();
if (QUANTUM <= current->remaining_burst) {
run(current, QUANTUM);
if (current->remaining_burst > 0) {
insert(&head, current);
}
}
else {
run(current, current->remaining_burst);
}
delete(&head, current);
}
Task* pickNextTask()
{
return head->task;
}
void schedule()
{
Task *current;
// print task list (sanity checker)
traverse(head);
current = pickNextTask();
run(current, current->burst);
delete(&head, current);
}
Task *pickNextTask()
{
int priority_min = 9999;
struct node* cur_node = head;
struct node* min_node = head;
while (cur_node != NULL) {
if (cur_node->task->priority < priority_min) {
priority_min = cur_node->task->priority;
min_node = cur_node;
}
cur_node = cur_node->next;
}
return min_node->task;
}
각 알고리즘 별 수행 결과
Algorithm | average waiting time |
---|---|
FCFS | 267.938 |
SJF | 160.438 |
RR | 236.000 |
Priority | 181.375 |