--- rpl/src/interruptions.c 2012/10/15 12:39:54 1.107 +++ rpl/src/interruptions.c 2013/02/27 17:11:45 1.118 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.11 - Copyright (C) 1989-2012 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.13 + Copyright (C) 1989-2013 Dr. BERTRAND Joël This file is part of RPL/2. @@ -81,6 +81,11 @@ thread_surveillance_signaux(void *argume volatile struct_liste_chainee_volatile *l_element_courant; + sigset_t set; + + sigfillset(&set); + pthread_sigmask(SIG_BLOCK, &set, NULL); + s_etat_processus = (struct_processus *) argument; for(;;) @@ -91,20 +96,20 @@ thread_surveillance_signaux(void *argume # if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) if (sem_wait(&(*s_queue_signaux).signalisation) == 0) # else - if(sem_wait(semaphore_signalisation) == 0) + if (sem_wait(semaphore_signalisation) == 0) # endif { - if ((*s_queue_signaux).requete_arret == d_vrai) - { - break; - } - # if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) sem_post(&(*s_queue_signaux).signalisation); # else sem_post(semaphore_signalisation); # endif + if ((*s_queue_signaux).requete_arret == d_vrai) + { + break; + } + nombre_signaux_envoyes = 0; sched_yield(); @@ -173,7 +178,10 @@ thread_surveillance_signaux(void *argume } else { - (*s_etat_processus).erreur_systeme = d_es_processus; + if (errno != EINTR) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + } } } @@ -332,10 +340,17 @@ retrait_thread(struct_processus *s_etat_ .pointeur_signal_lecture) { # if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) - sem_wait(&((*s_queue_signaux).signalisation)); + while(sem_wait(&((*s_queue_signaux).signalisation)) != 0) # else - sem_wait(semaphore_signalisation); + while(sem_wait(semaphore_signalisation) != 0) # endif + { + if (errno != EINTR) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + } (*(*((struct_thread *) (*l_element_courant).donnee)).s_etat_processus) .pointeur_signal_lecture = ((*(*((struct_thread *) @@ -534,6 +549,12 @@ liberation_threads(struct_processus *s_e struct_processus *candidat; + struct_liste_variables_partagees *l_element_partage_courant; + struct_liste_variables_partagees *l_element_partage_suivant; + + struct_liste_variables_statiques *l_element_statique_courant; + struct_liste_variables_statiques *l_element_statique_suivant; + unsigned long i; void *element_candidat; @@ -749,41 +770,38 @@ liberation_threads(struct_processus *s_e } } - liberation_arbre_variables(s_etat_processus, - (*s_etat_processus).s_arbre_variables, d_faux); - - // Ne peut être effacé qu'une seule fois + // ne peut être effacé qu'une seule fois if (suppression_variables_partagees == d_faux) { suppression_variables_partagees = d_vrai; - for(i = 0; i < (*(*s_etat_processus) - .s_liste_variables_partagees).nombre_variables; i++) - { - pthread_mutex_trylock(&((*(*(*s_etat_processus) - .s_liste_variables_partagees).table[i].objet) - .mutex)); - pthread_mutex_unlock(&((*(*(*s_etat_processus) - .s_liste_variables_partagees).table[i].objet) - .mutex)); + liberation_arbre_variables_partagees(s_etat_processus, + (*(*s_etat_processus).s_arbre_variables_partagees)); - liberation(s_etat_processus, (*(*s_etat_processus) - .s_liste_variables_partagees).table[i].objet); - free((*(*s_etat_processus).s_liste_variables_partagees) - .table[i].nom); - } + l_element_partage_courant = (*(*s_etat_processus) + .l_liste_variables_partagees); - if ((*(*s_etat_processus).s_liste_variables_partagees).table - != NULL) + while(l_element_partage_courant != NULL) { - free((struct_variable_partagee *) (*(*s_etat_processus) - .s_liste_variables_partagees).table); + l_element_partage_suivant = + (*l_element_partage_courant).suivant; + free(l_element_partage_courant); + l_element_partage_courant = l_element_partage_suivant; } + } - pthread_mutex_trylock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)); - pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)); + liberation_arbre_variables(s_etat_processus, + (*s_etat_processus).s_arbre_variables, d_faux); + + l_element_statique_courant = (*s_etat_processus) + .l_liste_variables_statiques; + + while(l_element_statique_courant != NULL) + { + l_element_statique_suivant = + (*l_element_statique_courant).suivant; + free(l_element_statique_courant); + l_element_statique_courant = l_element_statique_suivant; } element_courant = (*s_etat_processus).l_base_pile; @@ -2545,10 +2563,17 @@ scrutation_interruptions(struct_processu % LONGUEUR_QUEUE_SIGNAUX; # if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) - sem_wait(&((*s_queue_signaux).signalisation)); + while(sem_wait(&((*s_queue_signaux).signalisation)) != 0) # else - sem_wait(semaphore_signalisation); + while(sem_wait(semaphore_signalisation) != 0) # endif + { + if (errno != EINTR) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + } } # if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) @@ -2576,10 +2601,17 @@ scrutation_interruptions(struct_processu % LONGUEUR_QUEUE_SIGNAUX; # if (!defined(SEMAPHORES_NOMMES)) || defined(IPCS_SYSV) - sem_wait(&((*s_queue_signaux).signalisation)); + while(sem_wait(&((*s_queue_signaux).signalisation)) != 0) # else - sem_wait(semaphore_signalisation); + while(sem_wait(semaphore_signalisation) != 0) # endif + { + if (errno != EINTR) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + } } pthread_mutex_unlock(&mutex_interruptions);