diff --git a/SAE2 b/SAE2 index 28d9a5b..8779e81 100755 Binary files a/SAE2 and b/SAE2 differ diff --git a/includes/charge.h b/includes/charge.h index 7d8bd31..4c8c7fd 100644 --- a/includes/charge.h +++ b/includes/charge.h @@ -52,8 +52,8 @@ ListeDevis del(ListeDevis l); ListeDevis insert(ListeDevis l, Devis d); ListeDevis newListeDevis(void); Tache *trouverTache(Tache **tabTache, int nbTaches, char *nom); -Tache* defiler(ListeAttente *file); +Tache* defiler(ListeAttente *file); ListeAttente* initialiserFileAttente(void); -ListeAttente* traiterTaches(Tache **tabTache); +void traiterTaches(Tache *tabTache[]); diff --git a/obj/part4.o b/obj/part4.o index 90e870d..006357d 100644 Binary files a/obj/part4.o and b/obj/part4.o differ diff --git a/srcs/part4.c b/srcs/part4.c index 89e3e28..6bdcb75 100644 --- a/srcs/part4.c +++ b/srcs/part4.c @@ -1,35 +1,29 @@ #include "../includes/main.h" -ListeAttente* traiterTaches(Tache **tabTache) +void traiterTaches(Tache *tabTache[]) { - int i; - int dateCourante; - Tache *tacheCourante; - Tache *successeur; - Liste successeurs; - ListeAttente *file = initialiserFileAttente(); + ListeAttente file; + Liste succCourant; + file.debut = 0; + file.fin = 0; - for (i = 0; i < TMAXTRAV; i++) + for (int i = 0; i < TMAXTRAV; i++) if (tabTache[i]->nbPred == 0) - enfiler(file, tabTache[i]); + enfiler(&file, tabTache[i]); - while (!estVide(file)) + // Etape courante (utilisation d’une boucle) + while (!estVide(&file)) { - tacheCourante = defiler(file); - dateCourante = tacheCourante->dateDebut; - successeurs = tacheCourante->succ; - - while (successeurs) + Tache *tacheActuelle = defiler(&file); + succCourant = tacheActuelle->succ; + while (succCourant) { - successeur = trouverTache(tabTache, TMAXTRAV, successeurs->tache); - successeur->dateDebut = max(successeur->dateDebut, dateCourante + tacheCourante->duree); + Tache *successeur = trouverTache(tabTache, TMAXTRAV, succCourant->tache); + successeur->dateDebut = max(successeur->dateDebut, tacheActuelle->dateDebut + tacheActuelle->duree); successeur->nbPred--; - if (successeur->nbPred == 0) - enfiler(file, successeur); - successeurs = successeurs->nxt; + enfiler(&file, successeur); + succCourant = succCourant->nxt; } } - - return (file); } diff --git a/srcs/structures.c b/srcs/structures.c index 65ffc3f..f9da3bb 100644 --- a/srcs/structures.c +++ b/srcs/structures.c @@ -151,14 +151,16 @@ ListeDevis del(ListeDevis l) } //file -Tache* defiler(ListeAttente *file) +Tache* defiler(ListeAttente *file) { Tache *tache; - if (file->debut == file->fin) - return (NULL); + if (file->debut == file->fin) + return NULL; + tache = file->tab[file->debut]; file->debut = (file->debut + 1) % TMAXTRAV; + return (tache); } /*---------------calculs----------------*/