Skip to content
Snippets Groups Projects
Commit 0559ac36 authored by haoczhao's avatar haoczhao
Browse files

free

parent df87e61d
Branches master
No related tags found
No related merge requests found
Pipeline #67997 failed
...@@ -36,5 +36,3 @@ int main(int argc, char *argv[]) ...@@ -36,5 +36,3 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
...@@ -61,7 +61,7 @@ void show_stat(int timer, int *turn_around_array, int *ini_exe_array, int num_pr ...@@ -61,7 +61,7 @@ void show_stat(int timer, int *turn_around_array, int *ini_exe_array, int num_pr
int find_sub_process(int parallel_pro_id, process_t **cpu_queue, int queue_len); int find_sub_process(int parallel_pro_id, process_t **cpu_queue, int queue_len);
int adding_new_process(process_t **new_processes, process_t **all_process_array, int adding_new_process(process_t **new_processes, process_t **all_process_array,
int num_process, int timer, int *rest_proc); int num_process, int timer, int *rest_proc);
void free_all_process_array(process_t** all_process_array);
/* task1 */ /* task1 */
......
...@@ -84,6 +84,7 @@ void check_finished_pro_T1(process_t *cur_processing_pro, int *rest_proc, int ti ...@@ -84,6 +84,7 @@ void check_finished_pro_T1(process_t *cur_processing_pro, int *rest_proc, int ti
/* record information for the performance statistics*/ /* record information for the performance statistics*/
record_perform_info(turn_around_array, ini_exe_array, performance_index, cur_processing_pro, timer); record_perform_info(turn_around_array, ini_exe_array, performance_index, cur_processing_pro, timer);
free(cur_processing_pro);
} }
} }
......
...@@ -194,6 +194,8 @@ void processing_lst(int *finished_array_index, int *finished_array, process_t ** ...@@ -194,6 +194,8 @@ void processing_lst(int *finished_array_index, int *finished_array, process_t **
*finished_process += 1; *finished_process += 1;
} }
free(cur_processing_pro);
} }
} }
......
...@@ -71,6 +71,16 @@ void load_task3(process_t **all_process_array, int num_process, char *processors ...@@ -71,6 +71,16 @@ void load_task3(process_t **all_process_array, int num_process, char *processors
/* Performance statistics: */ /* Performance statistics: */
show_stat(timer, turn_around_array, ini_exe_array, num_process); show_stat(timer, turn_around_array, ini_exe_array, num_process);
/* free the all_cpu_lst */
for(int i=0; i<num_processors; i++){
for(int j=0;j<all_cpus_lst[i]->running_lst_len;j++){
free(all_cpus_lst[i]->cpu_running_lst[j]);
}
free(all_cpus_lst[i]->cpu_running_lst);
free(all_cpus_lst[i]);
}
free(all_cpus_lst);
} }
/* allocate all new arrive processes to cpus */ /* allocate all new arrive processes to cpus */
...@@ -259,6 +269,7 @@ void processing_each_cpu_lst(int *finished_process, int *rest_proc, int timer, l ...@@ -259,6 +269,7 @@ void processing_each_cpu_lst(int *finished_process, int *rest_proc, int timer, l
delete_head(cur_cpu_running_lst, &selected_cpu_lst->running_lst_len); delete_head(cur_cpu_running_lst, &selected_cpu_lst->running_lst_len);
*finished_process += 1; *finished_process += 1;
} }
free(cur_processing_pro);
} }
} }
......
...@@ -213,3 +213,14 @@ void record_perform_info(int *turn_around_array, int *ini_exe_array, int *perfor ...@@ -213,3 +213,14 @@ void record_perform_info(int *turn_around_array, int *ini_exe_array, int *perfor
ini_exe_array[*performance_index] = cur_processing_pro->ini_exe_time; ini_exe_array[*performance_index] = cur_processing_pro->ini_exe_time;
*performance_index += 1; *performance_index += 1;
} }
/* free the array*/
void free_all_process_array(process_t** all_process_array){
for(int i=0 ; i<PROCESS_SIZE; i++){
free(all_process_array[i]);
}
free(all_process_array);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment