1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2025-07-13 05:09:30 +00:00

Auront-ont vaincu la préemption ?

This commit is contained in:
Aethor
2018-06-22 00:48:43 +02:00
parent 7b2e3432ea
commit 86dabd455a
4 changed files with 12 additions and 10 deletions

View File

@ -33,7 +33,7 @@ void _free__Elevator(THIS(Elevator)){
void add_passenger_Elevator(THIS(Elevator), Passenger * passenger){
pthread_mutex_lock(&this->mutex_passengers);
this->passengers->insert_tail(this->passengers, ((void *)passenger), sizeof(Passenger));
printf("L'ascenseur %s recoit le visiteur %s à l'étage %d\nIl y a maintenant %d passagers dans l'ascenseur %s\n", this->name,
printf("L'ascenseur %s recoit le passager %s à l'étage %d\nIl y a maintenant %d passagers dans l'ascenseur %s\n", this->name,
passenger->get_name(passenger),
this->get_floor(this),
this->passengers->get_size(this->passengers), this->name);
@ -140,23 +140,20 @@ void *runnable_Elevator(void * void_this){
if(this->target_floor == this->get_floor(this)){
next_passenger_stop = this->get_next_passenger_stop(this);
next_call = building->get_next_call(building, this->floor);
if (!(next_passenger_stop == this->get_floor(this) || next_call == this->get_floor(this))){
printf("Ascenseur %s attends pour déposer ou prendre un pasager supplémentaire\n", this->name);
if (next_passenger_stop == this->get_floor(this) || next_call == this->get_floor(this)){
printf("Ascenseur %s attends pour déposer ou prendre un passager supplémentaire\n", this->name); //while pour attendre ?
}else{
if(next_passenger_stop != -1){
this->target_floor = next_passenger_stop;
}else if(next_call != -1){
this->target_floor = next_call;
}
}
}
}
if(this->get_floor(this) != this->target_floor){
this->set_floor(this, this->target_floor);
printf("Ascenseur %s en route vers l'étage %d\n", this->name, this->target_floor);
/*printf("DEBUG : Next passenger stop : %d\n", next_passenger_stop);
printf("DEBUG : Next call from user : %d\n", next_call);
printf("\n\n");*/
fflush(stdout);
}
}

View File

@ -11,7 +11,7 @@
#include "../Passenger/Passenger.h"
//#define MAX_ELEVATOR_CAPACITY 10
#define MAX_ELEVATOR_CAPACITY 3
#define MAX_ELEVATOR_CAPACITY 10
typedef enum {RUNNING, WAITING, SLEEPING, BROKEN} ELEVATOR_STATE;