mirror of
https://gitlab.com/klmp200/LO41.git
synced 2025-01-01 12:41:11 +00:00
FUCK YOU
This commit is contained in:
parent
bb1610d4fb
commit
6b7bb7e119
@ -41,10 +41,8 @@ void start_all_threads_SharedData(THIS(SharedData)){
|
|||||||
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;
|
||||||
this->threads = malloc_or_die(sizeof(pthread_t*) * this->threads_nb);
|
this->threads = malloc_or_die(sizeof(pthread_t*) * this->threads_nb);
|
||||||
|
|
||||||
for (i=0; i < this->threads_nb; i++){
|
for (i=0; i < this->threads_nb; i++)
|
||||||
this->threads[i] = NULL;
|
|
||||||
this->threads[i] = malloc_or_die(sizeof(pthread_t));
|
this->threads[i] = malloc_or_die(sizeof(pthread_t));
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_lock(&this->mutex_active_passengers);
|
pthread_mutex_lock(&this->mutex_active_passengers);
|
||||||
pthread_mutex_lock(&this->mutex_threads);
|
pthread_mutex_lock(&this->mutex_threads);
|
||||||
@ -99,8 +97,8 @@ void _free__SharedData(THIS(SharedData)){
|
|||||||
if (this->threads[i] != NULL) {
|
if (this->threads[i] != NULL) {
|
||||||
printf("Quitting thread %d\n", (*(int*) this->threads[i]));
|
printf("Quitting thread %d\n", (*(int*) this->threads[i]));
|
||||||
pthread_kill(*this->threads[i], SIGUSR1);
|
pthread_kill(*this->threads[i], SIGUSR1);
|
||||||
|
free(this->threads[i]);
|
||||||
}
|
}
|
||||||
free(this->threads[i]);
|
|
||||||
}
|
}
|
||||||
free(this->threads);
|
free(this->threads);
|
||||||
}
|
}
|
||||||
@ -131,6 +129,7 @@ void decrement_active_passengers_SharedData(THIS(SharedData)){
|
|||||||
|
|
||||||
void unregister_thread_SharedData(THIS(SharedData), int thread_number){
|
void unregister_thread_SharedData(THIS(SharedData), int thread_number){
|
||||||
pthread_mutex_lock(&this->mutex_threads);
|
pthread_mutex_lock(&this->mutex_threads);
|
||||||
|
free(this->threads[thread_number]);
|
||||||
this->threads[thread_number] = NULL;
|
this->threads[thread_number] = NULL;
|
||||||
pthread_mutex_unlock(&this->mutex_threads);
|
pthread_mutex_unlock(&this->mutex_threads);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user