From 1e66a95fbde8fef9bbf3c649b6501509ad208919 Mon Sep 17 00:00:00 2001 From: "florian.sauzeat" Date: Tue, 15 Oct 2024 11:15:59 +0200 Subject: [PATCH] =?UTF-8?q?fixer=20de=20mani=C3=A8re=20auto=20MAX=5FPROCES?= =?UTF-8?q?SES?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simulator.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/simulator.c b/simulator.c index c9166bf..38fd27a 100644 --- a/simulator.c +++ b/simulator.c @@ -4,7 +4,7 @@ #define RR_QUANTUM 2 #define CNTXT_SWITCH 1 -#define MAX_PROCESSES 10 +int MAX_PROCESSES = 0; enum pstate { WAITING, @@ -364,8 +364,8 @@ struct perf_info schedule_RR(struct pinfo *processes) { // Déclaration de la fo } void write_file(struct pinfo * process, struct perf_info * perf) { - FILE *myStream_execution = fopen("executionPr.csv", "w"); - FILE *myStream_performance = fopen("performancePr.csv", "w"); + FILE *myStream_execution = fopen("executionRR1.csv", "w"); + FILE *myStream_performance = fopen("performanceRR1.csv", "w"); if (myStream_execution == NULL || myStream_performance == NULL) { perror("Erreur à l'ouverture des fichiers"); @@ -404,6 +404,8 @@ struct pinfo * read_file() { struct pinfo * process; while (fgets(line, buf_size, file)) { + + MAX_PROCESSES += 1; pid_str = strtok(line, " "); arrival_str = strtok(NULL, " "); execution_str = strtok(NULL, " "); @@ -431,7 +433,10 @@ struct pinfo * read_file() { } free(line); fclose(file); + + printf("Maximum des processus : %d\n", MAX_PROCESSES); return first; + } void free_processes(struct pinfo * next) { @@ -449,8 +454,8 @@ int main() { struct pinfo * processes = read_file(); //struct perf_info perf = schedule_FCFS(processes); - //struct perf_info perf = schedule_RR(processes); - struct perf_info perf = schedule_Pr(processes); + struct perf_info perf = schedule_RR(processes); + //struct perf_info perf = schedule_Pr(processes); compute_waiting_time(processes);