Skip to content
Snippets Groups Projects
Commit f04c8f52 authored by Syufan's avatar Syufan
Browse files

fix fit sjf

parent bd16168a
No related branches found
No related tags found
No related merge requests found
......@@ -435,10 +435,11 @@ int main(int argc, char *argv[]) {
strcpy(processing->state, "FINISHED");
free_memory(memory_list,processing);
// move finished process from input list
move_node(input_list, processing);
// add all process except this cycle
//pickup_input(batch_list, input_list, simulated_time-quantum);
int proc_remaining = count_list(input_list);
printf("%d,%s,process_name=%s,proc_remaining=%d \n",simulated_time,processing->state,processing->process_name,proc_remaining);
// add all process
......@@ -482,7 +483,7 @@ int allocate_memory(queue_memory* q, process_n* process, int simulated_time){
// printf("count_memory = %d \n",count_memory);
// check the memeory size
if(count_memory < process->memory){
if(count_memory < process->memory && min_end == NULL){
return 0;
}
if (count_memory == process->memory){
......@@ -508,6 +509,7 @@ int allocate_memory(queue_memory* q, process_n* process, int simulated_time){
printf("%d,READY,process_name=%s,assigned_at=%d\n",simulated_time, process->process_name, temp_start->number);
return 1;
}else if(count_memory > process->memory){
//printf("compare\n");
if(min == -1){
min = count_memory;
min_start = temp_start;
......@@ -522,6 +524,7 @@ int allocate_memory(queue_memory* q, process_n* process, int simulated_time){
}
}
}
//printf("min satrt = %d, min end = %d\n",min_start->number, min_end->number);
//printf("bug2\n");
int position = find_position(min_start,q);
......@@ -678,6 +681,7 @@ process_n* search_shortest_process(queue_n* q){
// receive two list, put the process which arrived time is <= simulated_time
void pickup_input_task3(queue_n* batch_list, queue_n* input_list, int simulated_time, queue_memory* memory_list){
process_n* temp = batch_list->head;
while (temp != NULL) {
//find arrive time <=> simulated-time
if(temp->arrival_time <= simulated_time){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment