1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2025-07-12 04:39:23 +00:00

A mort les state, mais la préemption est toujours forte vis-à-vis des résidents

This commit is contained in:
Aethor
2018-06-22 00:04:52 +02:00
parent 036d4b55b7
commit 7b2e3432ea
2 changed files with 19 additions and 7 deletions

View File

@ -199,7 +199,9 @@ void go_to_floor_Building(THIS(Building), int origin, int destination, Passenger
if (destination < 0 || destination >= FLOORS) {CRASH("You are trying to reach a non existing floor\n");}
this->waiting_floors[origin]++;//on ajoute à la liste des attentes
pthread_mutex_lock(this->mutex_cond_get_inside_elevator);
pthread_cond_wait(this->condition_floors[origin], this->mutex_cond_get_inside_elevator);
pthread_mutex_unlock(this->mutex_cond_get_inside_elevator);
elevator_number = this->get_inside_elevator(this, origin, passenger);
if (elevator_number != -1){ //passenger accepted in elevator
@ -212,6 +214,7 @@ void go_to_floor_Building(THIS(Building), int origin, int destination, Passenger
else if (passenger->type == VISITOR)
printf("Le visiteur %s à l'étage %d n'a pas pu rentrer dans un ascenseur. Préempté !\n", passenger->get_name(passenger), origin);
//reloading fire
this->waiting_floors[origin]--;
this->go_to_floor(this, origin, destination, passenger);
}