fixer de manière auto MAX_PROCESSES
This commit is contained in:
parent
aee7447c21
commit
1e66a95fbd
15
simulator.c
15
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user