Skip to content

Commit

Permalink
totally solve percentage problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Tian-Qiu-988121 committed Jun 3, 2020
1 parent d2bc1b5 commit d98a29b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ run_p_on_ff_algorithm(list_t *process_input, long long int memory_size, statisti
remain_page = remain_page-page_need;
//calculate the memory take up percentage
//memory_take_up_per = ((double)page_need/memory_page)*100;
memory_take_up_per = ((double)(memory_page-remain_page)/memory_page)*100; //this is (2)
memory_take_up_per = ceil(((double)(memory_page-remain_page)/memory_page)*100); //this is (2)
}else{
printf("The memory is empty but there is still no space for the process!\n");
}
Expand Down Expand Up @@ -564,7 +564,7 @@ run_p_on_rr_algorithm(list_t *process_input,long long int memory_size, long long
// I am not sure the precentage is of the process take how much of the whole memory(1)
// or of how much taked up memory out of the whole memory(2), take (1) at here, can change later
//memory_take_up_per = ((double)page_need/memory_page)*100; //this is (1)
memory_take_up_per = ((double)(memory_page-remain_page)/memory_page)*100; //this is (2)
memory_take_up_per = ceil(((double)(memory_page-remain_page)/memory_page)*100); //this is (2)
printf("%lld, RUNNING, id=%lld, remaining-time=%lld, load-time=%lld, mem-usage=%d%%, mem-addresses=", simulator_timer, curr_process->process_id, curr_process->remain_time, curr_process->load_time, memory_take_up_per);
//printf("something wrong happened here!!!!\n");
print_take_up_page(curr_process->take_up_page, curr_process->page_num);
Expand Down

0 comments on commit d98a29b

Please sign in to comment.