--- rpl/src/instructions_p7.c 2012/04/13 14:12:58 1.44 +++ rpl/src/instructions_p7.c 2019/02/11 09:45:51 1.80 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.8 - Copyright (C) 1989-2012 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.31 + Copyright (C) 1989-2019 Dr. BERTRAND Joël This file is part of RPL/2. @@ -718,7 +718,8 @@ instruction_poke(struct_processus *s_eta return; } - if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0) + if (pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus)) + != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -749,11 +750,19 @@ instruction_poke(struct_processus *s_eta // figure ! action.sa_handler = SIG_IGN; - action.sa_flags = SA_ONSTACK; + action.sa_flags = 0; + + if (pthread_mutex_lock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } if (sigaction(SIGPIPE, &action, ®istre) != 0) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&mutex_sigaction); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); (*s_etat_processus).erreur_systeme = d_es_signal; return; @@ -765,7 +774,7 @@ instruction_poke(struct_processus *s_eta if (envoi_signal_processus((*(*((struct_processus_fils *) (*(*l_element_courant).donnee).objet)) - .thread).pid, rpl_siginject) != 0) + .thread).pid, rpl_siginject, d_faux) != 0) { // Le processus fils peut s'être terminé. break; @@ -783,11 +792,14 @@ instruction_poke(struct_processus *s_eta if ((*s_etat_processus).erreur_systeme != d_es) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&mutex_sigaction); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); return; } } + /* # ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) @@ -795,9 +807,11 @@ instruction_poke(struct_processus *s_eta if (sem_post((*s_etat_processus).semaphore_fork) != 0) # endif { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ while((longueur_ecriture = write_atomic(s_etat_processus, (*(*((struct_processus_fils *) @@ -805,6 +819,7 @@ instruction_poke(struct_processus *s_eta .pipe_nombre_injections[1], "-", sizeof(unsigned char))) != sizeof(unsigned char)) { + /* # ifndef SEMAPHORES_NOMMES while(sem_wait( &((*s_etat_processus).semaphore_fork)) != 0) @@ -820,10 +835,13 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (longueur_ecriture == -1) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&mutex_sigaction); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -850,6 +868,7 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_signal; return; @@ -858,6 +877,7 @@ instruction_poke(struct_processus *s_eta return; } + /* # ifndef SEMAPHORES_NOMMES if (sem_post( &((*s_etat_processus).semaphore_fork)) != 0) @@ -869,6 +889,7 @@ instruction_poke(struct_processus *s_eta (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ } if (ecriture_pipe(s_etat_processus, @@ -885,6 +906,7 @@ instruction_poke(struct_processus *s_eta } } + /* # ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) @@ -898,6 +920,7 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (registre_stop == 0) { @@ -919,12 +942,20 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&mutex_sigaction); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); (*s_etat_processus).erreur_systeme = d_es_signal; return; } + if (pthread_mutex_unlock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + break; } } @@ -951,12 +982,20 @@ instruction_poke(struct_processus *s_eta // de lecteur et on peut se prendre un SIGPIPE dans la // figure ! + if (pthread_mutex_lock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + action.sa_handler = SIG_IGN; - action.sa_flags = SA_ONSTACK; + action.sa_flags = 0; if (sigaction(SIGPIPE, &action, ®istre) != 0) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&mutex_sigaction); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); (*s_etat_processus).erreur_systeme = d_es_signal; return; @@ -970,6 +1009,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)).thread) .mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -978,7 +1018,8 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)).thread) .thread_actif == d_vrai) { - if (envoi_signal_thread((*(*((struct_processus_fils *) + if (envoi_signal_thread(s_etat_processus, + (*(*((struct_processus_fils *) (*(*l_element_courant).donnee).objet)).thread) .tid, rpl_siginject) != 0) { @@ -989,6 +1030,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)) .thread).mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1004,6 +1046,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)) .thread).mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1015,6 +1058,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)).thread) .mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1031,11 +1075,14 @@ instruction_poke(struct_processus *s_eta if ((*s_etat_processus).erreur_systeme != d_es) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&mutex_sigaction); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); return; } } + /* # ifndef SEMAPHORES_NOMMES if (sem_post( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1047,6 +1094,7 @@ instruction_poke(struct_processus *s_eta (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ while((longueur_ecriture = write_atomic(s_etat_processus, (*(*((struct_processus_fils *) @@ -1054,6 +1102,7 @@ instruction_poke(struct_processus *s_eta .pipe_nombre_injections[1], "-", sizeof(unsigned char))) != sizeof(unsigned char)) { + /* # ifndef SEMAPHORES_NOMMES while(sem_wait( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1069,10 +1118,12 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (longueur_ecriture == -1) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -1099,14 +1150,17 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_signal; return; } + pthread_mutex_unlock(&mutex_sigaction); return; } + /* # ifndef SEMAPHORES_NOMMES if (sem_post( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1118,6 +1172,7 @@ instruction_poke(struct_processus *s_eta (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ } if (ecriture_pipe(s_etat_processus, @@ -1134,6 +1189,7 @@ instruction_poke(struct_processus *s_eta } } + /* # ifndef SEMAPHORES_NOMMES while(sem_wait( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1148,6 +1204,7 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (registre_stop == 0) { @@ -1169,12 +1226,20 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&mutex_sigaction); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); (*s_etat_processus).erreur_systeme = d_es_signal; return; } + if (pthread_mutex_unlock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + break; } } @@ -1182,7 +1247,8 @@ instruction_poke(struct_processus *s_eta l_element_courant = (*l_element_courant).suivant; } - if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) + if (pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus)) + != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1284,26 +1350,12 @@ instruction_private(struct_processus *s_ return; } - if (pthread_mutex_lock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *) (*s_objet).objet)).nom), (*(*s_etat_processus) .pointeur_variable_courante).variable_partagee, (*(*s_etat_processus).pointeur_variable_courante).origine) - == d_faux) + == NULL) { - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - liberation(s_etat_processus, s_objet); (*s_etat_processus).erreur_systeme = d_es; @@ -1311,25 +1363,15 @@ instruction_private(struct_processus *s_ } (*(*s_etat_processus).pointeur_variable_courante).objet = - (*(*s_etat_processus).s_liste_variables_partagees).table - [(*(*s_etat_processus).s_liste_variables_partagees) - .position_variable].objet; - (*(*s_etat_processus).s_liste_variables_partagees).table - [(*(*s_etat_processus).s_liste_variables_partagees) - .position_variable].objet = NULL; + (*(*s_etat_processus).pointeur_variable_partagee_courante) + .objet; + (*(*s_etat_processus).pointeur_variable_partagee_courante).objet = NULL; if (retrait_variable_partagee(s_etat_processus, (*((struct_nom *) (*s_objet).objet)).nom, (*(*s_etat_processus).pointeur_variable_courante) .variable_partagee) == d_erreur) { - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - liberation(s_etat_processus, s_objet); return; } @@ -1344,13 +1386,6 @@ instruction_private(struct_processus *s_ (*(*s_etat_processus).pointeur_variable_courante) .variable_partagee.pointeur = NULL; } - - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } } else if ((*s_objet).type == LST) { @@ -1377,26 +1412,12 @@ instruction_private(struct_processus *s_ return; } - if (pthread_mutex_lock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *) (*s_objet).objet)).nom), (*(*s_etat_processus) .pointeur_variable_courante).variable_partagee, (*(*s_etat_processus).pointeur_variable_courante).origine) - == d_faux) + == NULL) { - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - liberation(s_etat_processus, s_objet); (*s_etat_processus).erreur_systeme = d_es; @@ -1406,12 +1427,10 @@ instruction_private(struct_processus *s_ } (*(*s_etat_processus).pointeur_variable_courante).objet = - (*(*s_etat_processus).s_liste_variables_partagees).table - [(*(*s_etat_processus).s_liste_variables_partagees) - .position_variable].objet; - (*(*s_etat_processus).s_liste_variables_partagees).table - [(*(*s_etat_processus).s_liste_variables_partagees) - .position_variable].objet = NULL; + (*(*s_etat_processus).pointeur_variable_partagee_courante) + .objet; + (*(*s_etat_processus).pointeur_variable_partagee_courante).objet + = NULL; if ((*(*s_etat_processus).pointeur_variable_courante).origine == 'P') @@ -1430,24 +1449,10 @@ instruction_private(struct_processus *s_ (*(*s_etat_processus).pointeur_variable_courante) .variable_statique) == d_erreur) { - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - liberation(s_etat_processus, s_objet); return; } - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - l_element_courant = (*l_element_courant).suivant; } }