mirror of
				https://gitlab.com/klmp200/LO41.git
				synced 2025-10-30 16:53:54 +00:00 
			
		
		
		
	Normalement c'est réglé, enfin
This commit is contained in:
		| @@ -38,7 +38,7 @@ void start_all_threads_SharedData(THIS(SharedData)){ | ||||
| 		else { | ||||
| 			residents = this->main_building->residents; | ||||
| 			visitors = this->main_building->visitors; | ||||
| 			this->threads_nb = residents->get_size(residents) + visitors->get_size(visitors) + ELEVATOR_NB; | ||||
| 			this->threads_nb = residents->get_size(residents) + visitors->get_size(visitors) + ELEVATOR_NB + 1; | ||||
| 			this->threads = malloc_or_die(sizeof(pthread_t*) * this->threads_nb); | ||||
|  | ||||
| 			for (i=0; i < this->threads_nb; i++) | ||||
| @@ -49,12 +49,27 @@ void start_all_threads_SharedData(THIS(SharedData)){ | ||||
|  | ||||
| 			 | ||||
| 			/* starts threading elevators */ | ||||
| 			for (i=1; i<ELEVATOR_NB; i++) { | ||||
| 			for (i=0; i<ELEVATOR_NB; i++) { | ||||
| 				this->start_thread(this, this->main_building->elevators[i]->runnable, | ||||
| 								   this->main_building->elevators[i], i); | ||||
| 				this->main_building->elevators[i]->set_thread_number(this->main_building->elevators[i], i); | ||||
| 			} | ||||
|  | ||||
| 			/* starting the elevator breaker */ | ||||
| 			this->start_thread(this, this->elevator_breaker->runnable, this->elevator_breaker, i); | ||||
| 			this->elevator_breaker->set_thread_number(this->elevator_breaker, i); | ||||
| 			i++; | ||||
|  | ||||
| 			/* starts threading residents */ | ||||
| 			current = residents->get_head(residents); | ||||
| 			while (current != NULL){ | ||||
| 				this->start_thread(this, ((Resident*)current->get_data(current))->runnable, current->get_data(current), i); | ||||
| 				((Resident*)current->get_data(current))->set_thread_number((Resident*)current->get_data(current), i); | ||||
| 				current = current->get_next(current); | ||||
| 				this->active_passengers++; | ||||
| 				i++; | ||||
| 			} | ||||
|  | ||||
| 			/* starts threading visitors */ | ||||
| 			current = visitors->get_head(visitors); | ||||
| 			while (current != NULL){ | ||||
| @@ -65,19 +80,6 @@ void start_all_threads_SharedData(THIS(SharedData)){ | ||||
| 				i++; | ||||
| 			} | ||||
|  | ||||
| 			/* starts threading residents */ | ||||
| 			current = residents->get_head(residents); | ||||
| 			while (current != NULL){ | ||||
| 				this->start_thread(this, ((Resident*)current->get_data(current))->runnable, current->get_data(current), i); | ||||
| 				((Resident*)current->get_data(current))->set_thread_number((Resident*)current->get_data(current), i); | ||||
| 				current = current->get_next(current); | ||||
| 				this->active_passengers++; | ||||
| 				i++; | ||||
| 			} | ||||
|  | ||||
| 			/* starting the elevator breaker */ | ||||
| 			this->start_thread(this, this->elevator_breaker->runnable, this->elevator_breaker, 0); | ||||
| 			this->elevator_breaker->set_thread_number(this->elevator_breaker, 0); | ||||
|  | ||||
| 			pthread_mutex_unlock(&this->mutex_threads); | ||||
| 			pthread_mutex_unlock(&this->mutex_active_passengers); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user