Diff for /rpl/src/instructions_p7.c between versions 1.25 and 1.78

version 1.25, 2011/06/20 17:54:19 version 1.78, 2019/02/03 14:40:50
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.0.prerelease.1    RPL/2 (R) version 4.1.31
   Copyright (C) 1989-2011 Dr. BERTRAND Joël    Copyright (C) 1989-2019 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
   
Line 718  instruction_poke(struct_processus *s_eta Line 718  instruction_poke(struct_processus *s_eta
             return;              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;              (*s_etat_processus).erreur_systeme = d_es_processus;
             return;              return;
Line 753  instruction_poke(struct_processus *s_eta Line 754  instruction_poke(struct_processus *s_eta
   
                     if (sigaction(SIGPIPE, &action, &registre) != 0)                      if (sigaction(SIGPIPE, &action, &registre) != 0)
                     {                      {
                         pthread_mutex_unlock(&((*s_etat_processus).mutex));                          pthread_mutex_unlock(&((*s_etat_processus)
                                   .mutex_pile_processus));
   
                         (*s_etat_processus).erreur_systeme = d_es_signal;                          (*s_etat_processus).erreur_systeme = d_es_signal;
                         return;                          return;
Line 763  instruction_poke(struct_processus *s_eta Line 765  instruction_poke(struct_processus *s_eta
                     // débloquer les instructions de type WF* pour les                      // débloquer les instructions de type WF* pour les
                     // lectures bloquantes.                      // lectures bloquantes.
   
                     if (kill((*(*((struct_processus_fils *)                      if (envoi_signal_processus((*(*((struct_processus_fils *)
                             (*(*l_element_courant).donnee).objet))                              (*(*l_element_courant).donnee).objet))
                             .thread).pid, SIGINJECT) != 0)                              .thread).pid, rpl_siginject, d_faux) != 0)
                     {                      {
                         // Le processus fils peut s'être terminé.                          // Le processus fils peut s'être terminé.
                         break;                          break;
Line 783  instruction_poke(struct_processus *s_eta Line 785  instruction_poke(struct_processus *s_eta
   
                         if ((*s_etat_processus).erreur_systeme != d_es)                          if ((*s_etat_processus).erreur_systeme != d_es)
                         {                          {
                             pthread_mutex_unlock(&((*s_etat_processus).mutex));                              pthread_mutex_unlock(&((*s_etat_processus)
                                       .mutex_pile_processus));
                             return;                              return;
                         }                          }
                     }                      }
   
 #                   ifndef SEMAPHORES_NOMMES  #                   ifndef SEMAPHORES_NOMMES
                     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)                          if (sem_post(&((*s_etat_processus).semaphore_fork))
                     {                                  != 0)
                         (*s_etat_processus).erreur_systeme = d_es_processus;  
                         return;  
                     }  
 #                   else  #                   else
                     if (sem_post((*s_etat_processus).semaphore_fork) != 0)                          if (sem_post((*s_etat_processus).semaphore_fork) != 0)
   #                   endif
                     {                      {
                         (*s_etat_processus).erreur_systeme = d_es_processus;                          (*s_etat_processus).erreur_systeme = d_es_processus;
                         return;                          return;
                     }                      }
 #                   endif  
   
                     while((longueur_ecriture = write_atomic(s_etat_processus,                      while((longueur_ecriture = write_atomic(s_etat_processus,
                             (*(*((struct_processus_fils *)                              (*(*((struct_processus_fils *)
Line 809  instruction_poke(struct_processus *s_eta Line 809  instruction_poke(struct_processus *s_eta
                             sizeof(unsigned char))) != sizeof(unsigned char))                              sizeof(unsigned char))) != sizeof(unsigned char))
                     {                      {
 #                       ifndef SEMAPHORES_NOMMES  #                       ifndef SEMAPHORES_NOMMES
                         while(sem_wait(&((*s_etat_processus)                              while(sem_wait(
                                 .semaphore_fork)) == -1)                                      &((*s_etat_processus).semaphore_fork)) != 0)
 #                       else  #                       else
                         while(sem_wait((*s_etat_processus)                              while(sem_wait(
                                 .semaphore_fork) == -1)                                      (*s_etat_processus).semaphore_fork) != 0)
 #                       endif  #                       endif
                         {                          {
                             if (errno != EINTR)                              if (errno != EINTR)
Line 826  instruction_poke(struct_processus *s_eta Line 826  instruction_poke(struct_processus *s_eta
   
                         if (longueur_ecriture == -1)                          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_1);
                             liberation(s_etat_processus, s_objet_argument_2);                              liberation(s_etat_processus, s_objet_argument_2);
Line 862  instruction_poke(struct_processus *s_eta Line 863  instruction_poke(struct_processus *s_eta
                         }                          }
   
 #                       ifndef SEMAPHORES_NOMMES  #                       ifndef SEMAPHORES_NOMMES
                         if (sem_post(&((*s_etat_processus)                              if (sem_post(
                                 .semaphore_fork)) != 0)                                      &((*s_etat_processus).semaphore_fork)) != 0)
 #                       else  #                       else
                         if (sem_post((*s_etat_processus)                              if (sem_post(
                                 .semaphore_fork) != 0)                                      (*s_etat_processus).semaphore_fork) != 0)
 #                       endif  #                       endif
                         {                          {
                             (*s_etat_processus).erreur_systeme = d_es_processus;                              (*s_etat_processus).erreur_systeme = d_es_processus;
Line 889  instruction_poke(struct_processus *s_eta Line 890  instruction_poke(struct_processus *s_eta
                     }                      }
   
 #                   ifndef SEMAPHORES_NOMMES  #                   ifndef SEMAPHORES_NOMMES
                     while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)                          while(sem_wait(&((*s_etat_processus).semaphore_fork))
                                   != 0)
 #                   else  #                   else
                     while(sem_wait((*s_etat_processus).semaphore_fork) == -1)                          while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
 #                   endif  #                   endif
                     {                      {
                         if (errno == EINTR)                          if (errno != EINTR)
                         {                          {
                             (*s_etat_processus).erreur_systeme = d_es_processus;                              (*s_etat_processus).erreur_systeme = d_es_processus;
                             return;                              return;
Line 921  instruction_poke(struct_processus *s_eta Line 923  instruction_poke(struct_processus *s_eta
   
                     if (sigaction(SIGPIPE, &registre, NULL) != 0)                      if (sigaction(SIGPIPE, &registre, NULL) != 0)
                     {                      {
                         pthread_mutex_unlock(&((*s_etat_processus).mutex));                          pthread_mutex_unlock(&((*s_etat_processus)
                                   .mutex_pile_processus));
   
                         (*s_etat_processus).erreur_systeme = d_es_signal;                          (*s_etat_processus).erreur_systeme = d_es_signal;
                         return;                          return;
Line 958  instruction_poke(struct_processus *s_eta Line 961  instruction_poke(struct_processus *s_eta
   
                     if (sigaction(SIGPIPE, &action, &registre) != 0)                      if (sigaction(SIGPIPE, &action, &registre) != 0)
                     {                      {
                         pthread_mutex_unlock(&((*s_etat_processus).mutex));                          pthread_mutex_unlock(&((*s_etat_processus)
                                   .mutex_pile_processus));
   
                         (*s_etat_processus).erreur_systeme = d_es_signal;                          (*s_etat_processus).erreur_systeme = d_es_signal;
                         return;                          return;
Line 980  instruction_poke(struct_processus *s_eta Line 984  instruction_poke(struct_processus *s_eta
                             (*(*l_element_courant).donnee).objet)).thread)                              (*(*l_element_courant).donnee).objet)).thread)
                             .thread_actif == d_vrai)                              .thread_actif == d_vrai)
                     {                      {
                         if (pthread_kill((*(*((struct_processus_fils *)                          if (envoi_signal_thread((*(*((struct_processus_fils *)
                                 (*(*l_element_courant).donnee).objet)).thread)                                  (*(*l_element_courant).donnee).objet)).thread)
                                 .tid, SIGINJECT) != 0)                                  .tid, rpl_siginject) != 0)
                         {                          {
                             // Le processus fils peut s'être terminé.                              // Le processus fils peut s'être terminé.
   
Line 1033  instruction_poke(struct_processus *s_eta Line 1037  instruction_poke(struct_processus *s_eta
   
                         if ((*s_etat_processus).erreur_systeme != d_es)                          if ((*s_etat_processus).erreur_systeme != d_es)
                         {                          {
                             pthread_mutex_unlock(&((*s_etat_processus).mutex));                              pthread_mutex_unlock(&((*s_etat_processus)
                                       .mutex_pile_processus));
                             return;                              return;
                         }                          }
                     }                      }
   
 #                   ifndef SEMAPHORES_NOMMES  #                   ifndef SEMAPHORES_NOMMES
                     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)                          if (sem_post(
                                   &((*s_etat_processus).semaphore_fork)) != 0)
 #                   else  #                   else
                     if (sem_post((*s_etat_processus).semaphore_fork) != 0)                          if (sem_post(
                                   (*s_etat_processus).semaphore_fork) != 0)
 #                   endif  #                   endif
                     {                      {
                         (*s_etat_processus).erreur_systeme = d_es_processus;                          (*s_etat_processus).erreur_systeme = d_es_processus;
Line 1055  instruction_poke(struct_processus *s_eta Line 1062  instruction_poke(struct_processus *s_eta
                             sizeof(unsigned char))) != sizeof(unsigned char))                              sizeof(unsigned char))) != sizeof(unsigned char))
                     {                      {
 #                       ifndef SEMAPHORES_NOMMES  #                       ifndef SEMAPHORES_NOMMES
                         while(sem_wait(&((*s_etat_processus)                              while(sem_wait(
                                 .semaphore_fork)) == -1)                                      &((*s_etat_processus).semaphore_fork)) != 0)
 #                       else  #                       else
                         while(sem_wait((*s_etat_processus)                              while(sem_wait(
                                 .semaphore_fork) == -1)                                      (*s_etat_processus).semaphore_fork) != 0)
 #                       endif  #                       endif
                         {                          {
                             if (errno != EINTR)                              if (errno != EINTR)
Line 1072  instruction_poke(struct_processus *s_eta Line 1079  instruction_poke(struct_processus *s_eta
   
                         if (longueur_ecriture == -1)                          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_1);
                             liberation(s_etat_processus, s_objet_argument_2);                              liberation(s_etat_processus, s_objet_argument_2);
Line 1108  instruction_poke(struct_processus *s_eta Line 1116  instruction_poke(struct_processus *s_eta
                         }                          }
   
 #                       ifndef SEMAPHORES_NOMMES  #                       ifndef SEMAPHORES_NOMMES
                         if (sem_post(&((*s_etat_processus)                              if (sem_post(
                                 .semaphore_fork)) != 0)                                      &((*s_etat_processus).semaphore_fork)) != 0)
 #                       else  #                       else
                         if (sem_post((*s_etat_processus)                              if (sem_post(
                                 .semaphore_fork) != 0)                                      (*s_etat_processus).semaphore_fork) != 0)
 #                       endif  #                       endif
                         {                          {
                             (*s_etat_processus).erreur_systeme = d_es_processus;                              (*s_etat_processus).erreur_systeme = d_es_processus;
Line 1135  instruction_poke(struct_processus *s_eta Line 1143  instruction_poke(struct_processus *s_eta
                     }                      }
   
 #                   ifndef SEMAPHORES_NOMMES  #                   ifndef SEMAPHORES_NOMMES
                     while(sem_wait(&((*s_etat_processus)                          while(sem_wait(
                             .semaphore_fork)) == -1)                                  &((*s_etat_processus).semaphore_fork)) != 0)
 #                   else  #                   else
                     while(sem_wait((*s_etat_processus)                          while(sem_wait(
                             .semaphore_fork) == -1)                                  (*s_etat_processus).semaphore_fork) != 0)
 #                   endif  #                   endif
                     {                      {
                         if (errno != EINTR)                          if (errno != EINTR)
Line 1169  instruction_poke(struct_processus *s_eta Line 1177  instruction_poke(struct_processus *s_eta
   
                     if (sigaction(SIGPIPE, &registre, NULL) != 0)                      if (sigaction(SIGPIPE, &registre, NULL) != 0)
                     {                      {
                         pthread_mutex_unlock(&((*s_etat_processus).mutex));                          pthread_mutex_unlock(&((*s_etat_processus)
                                   .mutex_pile_processus));
   
                         (*s_etat_processus).erreur_systeme = d_es_signal;                          (*s_etat_processus).erreur_systeme = d_es_signal;
                         return;                          return;
Line 1182  instruction_poke(struct_processus *s_eta Line 1191  instruction_poke(struct_processus *s_eta
             l_element_courant = (*l_element_courant).suivant;              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;              (*s_etat_processus).erreur_systeme = d_es_processus;
             return;              return;
Line 1284  instruction_private(struct_processus *s_ Line 1294  instruction_private(struct_processus *s_
             return;              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 *)          if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *)
                 (*s_objet).objet)).nom), (*(*s_etat_processus)                  (*s_objet).objet)).nom), (*(*s_etat_processus)
                 .pointeur_variable_courante).variable_partagee,                  .pointeur_variable_courante).variable_partagee,
                 (*(*s_etat_processus).pointeur_variable_courante).origine)                  (*(*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);              liberation(s_etat_processus, s_objet);
   
             (*s_etat_processus).erreur_systeme = d_es;              (*s_etat_processus).erreur_systeme = d_es;
Line 1311  instruction_private(struct_processus *s_ Line 1307  instruction_private(struct_processus *s_
         }          }
   
         (*(*s_etat_processus).pointeur_variable_courante).objet =          (*(*s_etat_processus).pointeur_variable_courante).objet =
                 (*(*s_etat_processus).s_liste_variables_partagees).table                  (*(*s_etat_processus).pointeur_variable_partagee_courante)
                 [(*(*s_etat_processus).s_liste_variables_partagees)                  .objet;
                 .position_variable].objet;          (*(*s_etat_processus).pointeur_variable_partagee_courante).objet = NULL;
         (*(*s_etat_processus).s_liste_variables_partagees).table  
                 [(*(*s_etat_processus).s_liste_variables_partagees)  
                 .position_variable].objet = NULL;  
   
         if (retrait_variable_partagee(s_etat_processus,          if (retrait_variable_partagee(s_etat_processus,
                 (*((struct_nom *) (*s_objet).objet)).nom,                  (*((struct_nom *) (*s_objet).objet)).nom,
                 (*(*s_etat_processus).pointeur_variable_courante)                  (*(*s_etat_processus).pointeur_variable_courante)
                 .variable_partagee) == d_erreur)                  .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);              liberation(s_etat_processus, s_objet);
             return;              return;
         }          }
Line 1344  instruction_private(struct_processus *s_ Line 1330  instruction_private(struct_processus *s_
             (*(*s_etat_processus).pointeur_variable_courante)              (*(*s_etat_processus).pointeur_variable_courante)
                     .variable_partagee.pointeur = NULL;                      .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)      else if ((*s_objet).type == LST)
     {      {
Line 1377  instruction_private(struct_processus *s_ Line 1356  instruction_private(struct_processus *s_
                 return;                  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 *)              if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *)
                     (*s_objet).objet)).nom), (*(*s_etat_processus)                      (*s_objet).objet)).nom), (*(*s_etat_processus)
                     .pointeur_variable_courante).variable_partagee,                      .pointeur_variable_courante).variable_partagee,
                     (*(*s_etat_processus).pointeur_variable_courante).origine)                      (*(*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);                  liberation(s_etat_processus, s_objet);
   
                 (*s_etat_processus).erreur_systeme = d_es;                  (*s_etat_processus).erreur_systeme = d_es;
Line 1406  instruction_private(struct_processus *s_ Line 1371  instruction_private(struct_processus *s_
             }              }
   
             (*(*s_etat_processus).pointeur_variable_courante).objet =              (*(*s_etat_processus).pointeur_variable_courante).objet =
                     (*(*s_etat_processus).s_liste_variables_partagees).table                      (*(*s_etat_processus).pointeur_variable_partagee_courante)
                     [(*(*s_etat_processus).s_liste_variables_partagees)                      .objet;
                     .position_variable].objet;              (*(*s_etat_processus).pointeur_variable_partagee_courante).objet
             (*(*s_etat_processus).s_liste_variables_partagees).table                      = NULL;
                     [(*(*s_etat_processus).s_liste_variables_partagees)  
                     .position_variable].objet = NULL;  
   
             if ((*(*s_etat_processus).pointeur_variable_courante).origine              if ((*(*s_etat_processus).pointeur_variable_courante).origine
                     == 'P')                      == 'P')
Line 1430  instruction_private(struct_processus *s_ Line 1393  instruction_private(struct_processus *s_
                     (*(*s_etat_processus).pointeur_variable_courante)                      (*(*s_etat_processus).pointeur_variable_courante)
                     .variable_statique) == d_erreur)                      .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);                  liberation(s_etat_processus, s_objet);
                 return;                  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;              l_element_courant = (*l_element_courant).suivant;
         }          }
     }      }

Removed from v.1.25  
changed lines
  Added in v.1.78


CVSweb interface <joel.bertrand@systella.fr>