version 1.5, 2010/03/06 18:29:07
|
version 1.16, 2010/05/19 09:22:34
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.12 |
RPL/2 (R) version 4.0.15 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 82 insertion_thread(struct_processus *s_eta
|
Line 82 insertion_thread(struct_processus *s_eta
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
while(sem_wait(&semaphore_liste_threads) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
== NULL) |
== NULL) |
{ |
{ |
sem_post(&semaphore_liste_threads); |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 105 insertion_thread(struct_processus *s_eta
|
Line 92 insertion_thread(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
(*l_nouvel_objet).suivant = liste_threads; |
|
|
|
if (((*l_nouvel_objet).donnee = malloc(sizeof(struct_thread))) == NULL) |
if (((*l_nouvel_objet).donnee = malloc(sizeof(struct_thread))) == NULL) |
{ |
{ |
sem_post(&semaphore_liste_threads); |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 124 insertion_thread(struct_processus *s_eta
|
Line 108 insertion_thread(struct_processus *s_eta
|
(*((struct_thread *) (*l_nouvel_objet).donnee)).s_etat_processus = |
(*((struct_thread *) (*l_nouvel_objet).donnee)).s_etat_processus = |
s_etat_processus; |
s_etat_processus; |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
(*l_nouvel_objet).suivant = liste_threads; |
|
|
liste_threads = l_nouvel_objet; |
liste_threads = l_nouvel_objet; |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
Line 152 insertion_thread_surveillance(struct_pro
|
Line 158 insertion_thread_surveillance(struct_pro
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
|
== NULL) |
|
{ |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_liste_threads) == -1) |
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 164 insertion_thread_surveillance(struct_pro
|
Line 184 insertion_thread_surveillance(struct_pro
|
} |
} |
} |
} |
|
|
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
|
== NULL) |
|
{ |
|
sem_post(&semaphore_liste_threads); |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*l_nouvel_objet).suivant = liste_threads_surveillance; |
(*l_nouvel_objet).suivant = liste_threads_surveillance; |
(*l_nouvel_objet).donnee = (void *) s_argument_thread; |
(*l_nouvel_objet).donnee = (void *) s_argument_thread; |
|
|
liste_threads_surveillance = l_nouvel_objet; |
liste_threads_surveillance = l_nouvel_objet; |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
Line 206 retrait_thread(struct_processus *s_etat_
|
Line 219 retrait_thread(struct_processus *s_etat_
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_liste_threads) == -1) |
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 236 retrait_thread(struct_processus *s_etat_
|
Line 253 retrait_thread(struct_processus *s_etat_
|
|
|
if (l_element_courant == NULL) |
if (l_element_courant == NULL) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&semaphore_liste_threads); |
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 253 retrait_thread(struct_processus *s_etat_
|
Line 274 retrait_thread(struct_processus *s_etat_
|
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
} |
} |
|
|
free((void *) (*l_element_courant).donnee); |
|
free((struct_liste_chainee_volatile *) l_element_courant); |
|
|
|
if (pthread_setspecific(semaphore_fork_processus_courant, NULL) != 0) |
if (pthread_setspecific(semaphore_fork_processus_courant, NULL) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&semaphore_liste_threads); |
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
return; |
return; |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
Line 275 retrait_thread(struct_processus *s_etat_
|
Line 301 retrait_thread(struct_processus *s_etat_
|
return; |
return; |
} |
} |
|
|
|
free((void *) (*l_element_courant).donnee); |
|
free((struct_liste_chainee_volatile *) l_element_courant); |
|
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
return; |
return; |
Line 293 retrait_thread_surveillance(struct_proce
|
Line 322 retrait_thread_surveillance(struct_proce
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_liste_threads) == -1) |
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 321 retrait_thread_surveillance(struct_proce
|
Line 354 retrait_thread_surveillance(struct_proce
|
|
|
if (l_element_courant == NULL) |
if (l_element_courant == NULL) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&semaphore_liste_threads); |
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 329 retrait_thread_surveillance(struct_proce
|
Line 366 retrait_thread_surveillance(struct_proce
|
return; |
return; |
} |
} |
|
|
|
// l_element_courant->donnee n'est pas bonne lorsque ça part en vrille. |
if (l_element_precedent == NULL) |
if (l_element_precedent == NULL) |
{ |
{ |
liste_threads_surveillance = (*l_element_courant).suivant; |
liste_threads_surveillance = (*l_element_courant).suivant; |
Line 338 retrait_thread_surveillance(struct_proce
|
Line 376 retrait_thread_surveillance(struct_proce
|
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
} |
} |
|
|
free((struct_liste_chainee_volatile *) l_element_courant); |
|
|
|
if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 359 retrait_thread_surveillance(struct_proce
|
Line 400 retrait_thread_surveillance(struct_proce
|
{ |
{ |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 373 retrait_thread_surveillance(struct_proce
|
Line 419 retrait_thread_surveillance(struct_proce
|
{ |
{ |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 381 retrait_thread_surveillance(struct_proce
|
Line 432 retrait_thread_surveillance(struct_proce
|
} |
} |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
Line 390 retrait_thread_surveillance(struct_proce
|
Line 445 retrait_thread_surveillance(struct_proce
|
return; |
return; |
} |
} |
|
|
|
free((struct_liste_chainee_volatile *) l_element_courant); |
|
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
return; |
return; |
Line 400 verrouillage_threads_concurrents(struct_
|
Line 457 verrouillage_threads_concurrents(struct_
|
{ |
{ |
volatile struct_liste_chainee_volatile *l_element_courant; |
volatile struct_liste_chainee_volatile *l_element_courant; |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_liste_threads) == -1) |
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 417 verrouillage_threads_concurrents(struct_
|
Line 478 verrouillage_threads_concurrents(struct_
|
== getpid()) && (pthread_equal((*((struct_thread *) |
== getpid()) && (pthread_equal((*((struct_thread *) |
(*l_element_courant).donnee)).tid, pthread_self()) == 0)) |
(*l_element_courant).donnee)).tid, pthread_self()) == 0)) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*(*((struct_thread *) (*l_element_courant) |
while(sem_wait(&((*(*((struct_thread *) (*l_element_courant) |
.donnee)).s_etat_processus).semaphore_fork)) == -1) |
.donnee)).s_etat_processus).semaphore_fork)) == -1) |
|
# else |
|
while(sem_wait((*(*((struct_thread *) (*l_element_courant) |
|
.donnee)).s_etat_processus).semaphore_fork) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 447 deverrouillage_threads_concurrents(struc
|
Line 513 deverrouillage_threads_concurrents(struc
|
== getpid()) && (pthread_equal((*((struct_thread *) |
== getpid()) && (pthread_equal((*((struct_thread *) |
(*l_element_courant).donnee)).tid, pthread_self()) == 0)) |
(*l_element_courant).donnee)).tid, pthread_self()) == 0)) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*(*((struct_thread *) |
if (sem_post(&((*(*((struct_thread *) |
(*l_element_courant).donnee)).s_etat_processus) |
(*l_element_courant).donnee)).s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*(*((struct_thread *) |
|
(*l_element_courant).donnee)).s_etat_processus) |
|
.semaphore_fork) != 0) |
|
# endif |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
# endif |
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 465 deverrouillage_threads_concurrents(struc
|
Line 545 deverrouillage_threads_concurrents(struc
|
l_element_courant = (*l_element_courant).suivant; |
l_element_courant = (*l_element_courant).suivant; |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 498 liberation_threads(struct_processus *s_e
|
Line 582 liberation_threads(struct_processus *s_e
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_liste_threads) == -1) |
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 539 liberation_threads(struct_processus *s_e
|
Line 627 liberation_threads(struct_processus *s_e
|
close((*s_etat_processus).pipe_nombre_objets_attente); |
close((*s_etat_processus).pipe_nombre_objets_attente); |
close((*s_etat_processus).pipe_nombre_interruptions_attente); |
close((*s_etat_processus).pipe_nombre_interruptions_attente); |
|
|
|
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
|
|
if ((*s_etat_processus).nom_fichier_impression != NULL) |
if ((*s_etat_processus).nom_fichier_impression != NULL) |
{ |
{ |
free((*s_etat_processus).nom_fichier_impression); |
free((*s_etat_processus).nom_fichier_impression); |
Line 1066 liberation_threads(struct_processus *s_e
|
Line 1156 liberation_threads(struct_processus *s_e
|
element_courant = element_suivant; |
element_courant = element_suivant; |
} |
} |
|
|
|
/* |
|
================================================================================ |
|
À noter : on ne ferme pas la connexion car la conséquence immédiate est |
|
une destruction de l'objet pour le processus père. |
|
================================================================================ |
|
|
element_courant = (*s_etat_processus).s_connecteurs_sql; |
element_courant = (*s_etat_processus).s_connecteurs_sql; |
while(element_courant != NULL) |
while(element_courant != NULL) |
{ |
{ |
Line 1149 liberation_threads(struct_processus *s_e
|
Line 1245 liberation_threads(struct_processus *s_e
|
|
|
element_courant = element_suivant; |
element_courant = element_suivant; |
} |
} |
|
*/ |
|
|
|
(*s_etat_processus).s_connecteurs_sql = NULL; |
|
|
element_courant = (*s_etat_processus).s_marques; |
element_courant = (*s_etat_processus).s_marques; |
while(element_courant != NULL) |
while(element_courant != NULL) |
Line 1163 liberation_threads(struct_processus *s_e
|
Line 1262 liberation_threads(struct_processus *s_e
|
|
|
liberation_allocateur(s_etat_processus); |
liberation_allocateur(s_etat_processus); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
|
# else |
|
sem_post((*s_etat_processus).semaphore_fork); |
|
sem_destroy2((*s_etat_processus).semaphore_fork, sem_fork); |
|
# endif |
|
|
free(s_etat_processus); |
free(s_etat_processus); |
|
|
Line 1199 liberation_threads(struct_processus *s_e
|
Line 1303 liberation_threads(struct_processus *s_e
|
if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
return; |
return; |
} |
} |
|
|
Line 1213 liberation_threads(struct_processus *s_e
|
Line 1318 liberation_threads(struct_processus *s_e
|
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
return; |
return; |
} |
} |
|
|
Line 1224 liberation_threads(struct_processus *s_e
|
Line 1330 liberation_threads(struct_processus *s_e
|
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
return; |
return; |
} |
} |
} |
} |
Line 1235 liberation_threads(struct_processus *s_e
|
Line 1342 liberation_threads(struct_processus *s_e
|
|
|
liste_threads_surveillance = NULL; |
liste_threads_surveillance = NULL; |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
Line 1358 verrouillage_gestionnaire_signaux()
|
Line 1469 verrouillage_gestionnaire_signaux()
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_gestionnaires_signaux_atomique) == -1) |
while(sem_wait(&semaphore_gestionnaires_signaux_atomique) == -1) |
|
# else |
|
while(sem_wait(semaphore_gestionnaires_signaux_atomique) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 1368 verrouillage_gestionnaire_signaux()
|
Line 1483 verrouillage_gestionnaire_signaux()
|
} |
} |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_gestionnaires_signaux) == -1) |
if (sem_post(&semaphore_gestionnaires_signaux) == -1) |
|
# else |
|
if (sem_post(semaphore_gestionnaires_signaux) == -1) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
BUG(1, uprintf("Lock error !\n")); |
BUG(1, uprintf("Lock error !\n")); |
return; |
return; |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_getvalue(&semaphore_gestionnaires_signaux, &semaphore) != 0) |
if (sem_getvalue(&semaphore_gestionnaires_signaux, &semaphore) != 0) |
|
# else |
|
if (sem_getvalue(semaphore_gestionnaires_signaux, &semaphore) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
BUG(1, uprintf("Lock error !\n")); |
BUG(1, uprintf("Lock error !\n")); |
return; |
return; |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_gestionnaires_signaux_atomique) != 0) |
if (sem_post(&semaphore_gestionnaires_signaux_atomique) != 0) |
|
# else |
|
if (sem_post(semaphore_gestionnaires_signaux_atomique) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
BUG(1, uprintf("Unlock error !\n")); |
BUG(1, uprintf("Unlock error !\n")); |
Line 1397 verrouillage_gestionnaire_signaux()
|
Line 1524 verrouillage_gestionnaire_signaux()
|
// par un thread concurrent. On essaye donc de le bloquer jusqu'à |
// par un thread concurrent. On essaye donc de le bloquer jusqu'à |
// ce que ce soit possible. |
// ce que ce soit possible. |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_trywait(&semaphore_liste_threads) == -1) |
while(sem_trywait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_trywait(semaphore_liste_threads) == -1) |
|
# endif |
{ |
{ |
if ((errno != EINTR) && (errno != EAGAIN)) |
if ((errno != EINTR) && (errno != EAGAIN)) |
{ |
{ |
Line 1441 deverrouillage_gestionnaire_signaux()
|
Line 1572 deverrouillage_gestionnaire_signaux()
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_gestionnaires_signaux_atomique) == -1) |
while(sem_wait(&semaphore_gestionnaires_signaux_atomique) == -1) |
|
# else |
|
while(sem_wait(semaphore_gestionnaires_signaux_atomique) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 1451 deverrouillage_gestionnaire_signaux()
|
Line 1586 deverrouillage_gestionnaire_signaux()
|
} |
} |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_getvalue(&semaphore_gestionnaires_signaux, &semaphore) != 0) |
if (sem_getvalue(&semaphore_gestionnaires_signaux, &semaphore) != 0) |
|
# else |
|
if (sem_getvalue(semaphore_gestionnaires_signaux, &semaphore) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
BUG(1, uprintf("Unlock error !\n")); |
BUG(1, uprintf("Unlock error !\n")); |
return; |
return; |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_gestionnaires_signaux) == -1) |
while(sem_wait(&semaphore_gestionnaires_signaux) == -1) |
|
# else |
|
while(sem_wait(semaphore_gestionnaires_signaux) == -1) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 1468 deverrouillage_gestionnaire_signaux()
|
Line 1611 deverrouillage_gestionnaire_signaux()
|
} |
} |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_gestionnaires_signaux_atomique) != 0) |
if (sem_post(&semaphore_gestionnaires_signaux_atomique) != 0) |
|
# else |
|
if (sem_post(semaphore_gestionnaires_signaux_atomique) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
BUG(1, uprintf("Unlock error !\n")); |
BUG(1, uprintf("Unlock error !\n")); |
Line 1491 deverrouillage_gestionnaire_signaux()
|
Line 1638 deverrouillage_gestionnaire_signaux()
|
|
|
if (semaphore == 1) |
if (semaphore == 1) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&semaphore_liste_threads) != 0) |
if (sem_post(&semaphore_liste_threads) != 0) |
|
# else |
|
if (sem_post(semaphore_liste_threads) != 0) |
|
# endif |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
|
Line 1846 interruption5(int signal, siginfo_t *sig
|
Line 1997 interruption5(int signal, siginfo_t *sig
|
} |
} |
else |
else |
{ |
{ |
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
|
== NULL) |
|
{ |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
// Envoi d'un signal au thread maître du groupe. |
// Envoi d'un signal au thread maître du groupe. |
|
|
if (recherche_thread_principal(getpid(), &thread) == d_vrai) |
if (recherche_thread_principal(getpid(), &thread) == d_vrai) |
{ |
{ |
pthread_kill(thread, SIGFSTOP); |
pthread_kill(thread, signal); |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
return; |
return; |
} |
} |
Line 1974 interruption9(int signal, siginfo_t *sig
|
Line 2132 interruption9(int signal, siginfo_t *sig
|
fflush(stdout); |
fflush(stdout); |
} |
} |
|
|
pthread_kill((*s_etat_processus).tid_processus_pere, SIGFSTOP); |
pthread_kill((*s_etat_processus).tid_processus_pere, SIGFABORT); |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
return; |
return; |
} |
} |
Line 2017 interruption10(int signal, siginfo_t *si
|
Line 2175 interruption10(int signal, siginfo_t *si
|
} |
} |
|
|
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
|
void |
|
interruption11(int signal, siginfo_t *siginfo, void *context) |
|
{ |
|
pthread_t thread; |
|
struct_processus *s_etat_processus; |
|
|
|
verrouillage_gestionnaire_signaux(); |
|
|
|
if ((*siginfo).si_pid == getpid()) |
|
{ |
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
|
== NULL) |
|
{ |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
|
(*s_etat_processus).arret_depuis_abort = -1; |
|
|
|
if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) |
|
{ |
|
printf("[%d] SIGFABORT (thread %llu)\n", (int) getpid(), |
|
(unsigned long long) pthread_self()); |
|
fflush(stdout); |
|
} |
|
|
|
/* |
|
* var_globale_traitement_retarde_stop : |
|
* 0 -> traitement immédiat |
|
* 1 -> traitement retardé (aucun signal reçu) |
|
* -1 -> traitement retardé (un ou plusieurs signaux stop reçus) |
|
*/ |
|
|
|
if ((*s_etat_processus).var_volatile_traitement_retarde_stop == 0) |
|
{ |
|
(*s_etat_processus).var_volatile_requete_arret = -1; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).var_volatile_traitement_retarde_stop = -1; |
|
} |
|
} |
|
else |
|
{ |
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
|
== NULL) |
|
{ |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
|
(*s_etat_processus).arret_depuis_abort = -1; |
|
|
|
// Envoi d'un signal au thread maître du groupe. |
|
|
|
if (recherche_thread_principal(getpid(), &thread) == d_vrai) |
|
{ |
|
pthread_kill(thread, signal); |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
} |
|
|
|
deverrouillage_gestionnaire_signaux(); |
return; |
return; |
} |
} |
|
|